From ff6013b60327e214a6f6249d8045f819bdeb1fac Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 26 Oct 2019 09:55:59 +0200 Subject: [PATCH] parser: allow semicolons to finish arguments early Similarly to how parentheses are omitted at the end of commands, this change allows them to be omitted at the end of function arguments. Notice however than this omission is *ambiguous* when the parser does not know in advance the number of arguments. GCD(Ent(x;y -> GCD(Ent(x;y)) -> GCD(Ent(x);y) The fx-92 SC+ parser knows the number of arguments for each function, and will use the second interpretation, because Ent() has one argument and GCD() has two. This interpreter, however, uses a generic extensible construction for function calls and cannot decide on this ground. The current interpretation is the first. --- fx92/drawing.py | 2 +- fx92/parser.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fx92/drawing.py b/fx92/drawing.py index 904a314..7048a04 100644 --- a/fx92/drawing.py +++ b/fx92/drawing.py @@ -199,7 +199,7 @@ class Window: """Push window contents on-screen.""" if self.stream: - name = "{:04d}.png".format(self.streamid) + name = "{:04d}.bmp".format(self.streamid) self.save(os.path.join(self.stream, name)) self.streamid += 1 diff --git a/fx92/parser.py b/fx92/parser.py index aa91cff..178a4a6 100644 --- a/fx92/parser.py +++ b/fx92/parser.py @@ -249,7 +249,7 @@ class Parser: e = self.expr() # Allow a parenthesis to be removed at the end of a parameter - optional = (self.la.type == T.PARAM) + optional = (self.la.type in [T.PARAM, T.SEMI]) self.expect(T.RPAR, optional=optional) return Node(N.EXP, a, e) @@ -270,7 +270,7 @@ class Parser: e = self.expr() # Allow a parenthesis to be removed at the end of a parameter - optional = (self.la.type == T.PARAM) + optional = (self.la.type in [T.PARAM, T.SEMI]) self.expect(T.RPAR, optional=optional) return e @@ -279,7 +279,7 @@ class Parser: a = self.funargs() # Allow a parenthesis to be removed at the end of a parameter - optional = (self.la.type == T.PARAM) + optional = (self.la.type in [T.PARAM, T.SEMI]) self.expect(T.RPAR, optional=optional) return Node(N.FUN, name, a)