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.
This commit is contained in:
parent
f1cc4ace40
commit
ff6013b603
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue