Skip to content

Commit 8bc1a48

Browse files
committed
fix(parser): expressions with more than one plus or minus
1 parent eb60109 commit 8bc1a48

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

docs/CFG-EBNF.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
27. *Datatype* -> __int__ | __float__ | __string__
6161

62-
28. *Expression* -> *Term* ( ( __-__ | __+__ ) *Term* )?
62+
28. *Expression* -> *Term* ( ( __-__ | __+__ ) *Expression* )?
6363

6464
29. *Term* -> *Factor* ( ( __*__ | __/__ ) *Term* )?
6565

docs/CFG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
31. *Datatype* -> __int__ | __float__ | __string__
6969

70-
32. *Expression* -> *Term* ( ( __-__ | __+__ ) *Term* | $\epsilon$ )
70+
32. *Expression* -> *Term* ( ( __-__ | __+__ ) *Expression* | $\epsilon$ )
7171

7272
33. *Term* -> *Factor* ( ( __*__ | __/__ ) *Term* | $\epsilon$ )
7373

src/TinyCompiler/Parser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ private Node Expr()
447447
if (Match(TokenClass.Minus, TokenClass.Plus))
448448
{
449449
n.Children.Add(PreviousNode());
450-
n.Children.Add(Term());
450+
n.Children.Add(Expr());
451451
}
452452

453453
return n;

0 commit comments

Comments
 (0)