xipd

programming language for audio processing that compiles to PureData
git clone https://git.ce9e.org/xipd.git

commit
c3a0d731582d18706339bfbd010899685ccf09d9
parent
2093dd6b6a2311f324bab65c8ce0200b4eeb742a
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2022-09-02 06:52
allow expressions as statements

Diffstat

M README.md 3 +++
M xipd/parser.py 1 +
M xipd/renderer.py 2 +-

3 files changed, 5 insertions, 1 deletions


diff --git a/README.md b/README.md

@@ -108,6 +108,9 @@ of the following patterns:
  108   108 -   **Return**: Each function must return an expression. This should be the
  109   109     last statement of the function because no further statements are executed.
  110   110     (e.g. `return foo:1`)
   -1   111 -   **Expression**: Sometimes it is useful to have expressions (especially
   -1   112     function calls) without assigning them to a name, just for their side
   -1   113     effects.
  111   114 
  112   115 ## Low-level language
  113   116 

diff --git a/xipd/parser.py b/xipd/parser.py

@@ -196,6 +196,7 @@ class Parser:
  196   196 			self.parse_assign,
  197   197 			self.parse_startfunc,
  198   198 			self.parse_endfunc,
   -1   199 			self.parse_expr,
  199   200 		], parse_to_end=True)
  200   201 		return ast
  201   202 

diff --git a/xipd/renderer.py b/xipd/renderer.py

@@ -126,7 +126,7 @@ class Renderer:
  126   126 				_, name, params, body = stmt
  127   127 				scope.add_func(name, (params, body, path))
  128   128 			else:
  129    -1 				raise SyntaxError('invalid statement', stmt)
   -1   129 				self.expr_to_ref(stmt, scope)
  130   130 
  131   131 	def render(self, fh):
  132   132 		scope = Scope()