electr 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +77 -50
- data/bin/electr +1 -5
- data/electr.gemspec +1 -1
- data/lib/electr.rb +10 -9
- data/lib/electr/ast.rb +1 -0
- data/lib/electr/ast/ast.rb +1 -0
- data/lib/electr/ast/variable_ast.rb +13 -0
- data/lib/electr/compiler.rb +0 -1
- data/lib/electr/exceptions.rb +6 -0
- data/lib/electr/option.rb +2 -2
- data/lib/electr/parser/lexer.rb +2 -0
- data/lib/electr/parser/lexical_unit.rb +9 -0
- data/lib/electr/parser/rules/expression_rule.rb +17 -2
- data/lib/electr/parser/sya.rb +70 -11
- data/lib/electr/parser/token.rb +7 -2
- data/lib/electr/parser/tokenizer.rb +20 -4
- data/lib/electr/repl.rb +1 -0
- data/lib/electr/repl/electr_value.rb +78 -0
- data/lib/electr/repl/evaluator.rb +92 -7
- data/lib/electr/repl/printer.rb +26 -3
- data/lib/electr/version.rb +2 -2
- data/spec/compiler_spec.rb +62 -3
- data/spec/parser/lexer_spec.rb +5 -0
- data/spec/parser/sya_spec.rb +64 -0
- data/spec/parser/tokenizer_spec.rb +13 -0
- data/spec/repl/electr_value_spec.rb +86 -0
- data/spec/repl/evaluator_spec.rb +112 -3
- data/spec/repl/printer_spec.rb +42 -2
- data/spec/repl/repl_spec.rb +1 -1
- metadata +7 -6
- data/documentation/developer.md +0 -21
- data/documentation/grammar.md +0 -34
- data/documentation/precedence.md +0 -10
data/documentation/grammar.md
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# Grammar of Electr in EBNF
|
2
|
-
|
3
|
-
expression = [`(`], number {[op] expression}, [`)`];
|
4
|
-
|
5
|
-
number = numeric | value | constant | f-call;
|
6
|
-
|
7
|
-
numeric = integer | float;
|
8
|
-
|
9
|
-
integer = ? integer ?;
|
10
|
-
|
11
|
-
float = ? floating point number ?;
|
12
|
-
|
13
|
-
value = ? integer or floating point directly followed by a unit ?;
|
14
|
-
|
15
|
-
constant = `pi`;
|
16
|
-
|
17
|
-
(* function call *)
|
18
|
-
f-call = f-name, `(`, expression, `)`;
|
19
|
-
|
20
|
-
(* function name *)
|
21
|
-
f-name = ? regexp: [a-z]{1,} ?;
|
22
|
-
|
23
|
-
(* operators *)
|
24
|
-
op = `-` | `+` | `/`;
|
25
|
-
|
26
|
-
## Precisions
|
27
|
-
|
28
|
-
### Negative numbers
|
29
|
-
|
30
|
-
`-123` is a negative number.<br/>
|
31
|
-
`- 123` is not.
|
32
|
-
|
33
|
-
This is because the multiplication is implicit, ie `2 - 3` equals `-1` and
|
34
|
-
`2 -3` equals `-6`.
|
data/documentation/precedence.md
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
Precedence Table
|
2
|
-
================
|
3
|
-
|
4
|
-
Operator | Description | Associativity
|
5
|
-
:-------: | ------------- | --------------
|
6
|
-
() | Function call | Left
|
7
|
-
^ | Exponent | Left
|
8
|
-
- | Unary minus | Right
|
9
|
-
* / | Multiplication and division | Left
|
10
|
-
+ - | Addition and substraction | Left
|