summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhenshin26
-rw-r--r--test/test.test4
2 files changed, 24 insertions, 6 deletions
diff --git a/henshin b/henshin
index d393f23..53611f8 100755
--- a/henshin
+++ b/henshin
@@ -269,6 +269,11 @@ class AstNodeLoop(AstNode):
self.value_id = value_id
self.body = body
+class AstNodePipe(AstNode):
+ def __init__(self, left, right):
+ self.left = left
+ self.right = right
+
precedence = (
@@ -318,8 +323,9 @@ def p_statement(p):
'''statement : variable_declaration_statement
| variable_reassignment_statement
| function_declaration
- | function_call
+ | function_call SEMICOLON
| loop
+ | pipe SEMICOLON
| return_statement'''
p[0] = p[1]
@@ -355,7 +361,7 @@ def p_function_declaration_parameter(p):
def p_function_call(p):
- '''function_call : IDENTIFIER PARENTHESIS_LEFT function_call_parameters PARENTHESIS_RIGHT SEMICOLON'''
+ '''function_call : IDENTIFIER PARENTHESIS_LEFT function_call_parameters PARENTHESIS_RIGHT'''
p[0] = AstNodeFunctionCall(p[1], p[3])
@@ -366,7 +372,9 @@ def p_function_call_parameters(p):
| function_call_parameter
|'''
- parameters = [p[1]]
+ parameters = []
+ if len(p) == 2:
+ parameters.append(p[1])
if len(p) == 4:
parameters.extend(p[3])
@@ -375,7 +383,8 @@ def p_function_call_parameters(p):
def p_function_call_parameter(p):
'''function_call_parameter : IDENTIFIER ASSIGN expression
- | expression'''
+ | expression
+ | OPERATOR_PIPE_REPLACEMENT'''
if len(p) == 4:
p[0] = AstNodeFunctionCallParameter(p[1], p[3])
@@ -393,6 +402,15 @@ def p_loop(p):
+def p_pipe(p):
+ '''pipe : expression OPERATOR_PIPE pipe
+ | expression OPERATOR_PIPE function_call'''
+
+ p[0] = AstNodePipe(p[1], p[3])
+
+
+
+
def p_variable_declaration_statement(p):
'''variable_declaration_statement : variable_declarator IDENTIFIER COLON variable_type ASSIGN expression SEMICOLON'''
diff --git a/test/test.test b/test/test.test
index 24059ca..e39eae6 100644
--- a/test/test.test
+++ b/test/test.test
@@ -32,5 +32,5 @@ for (map) |key, value| {
ply = key;
}
-std.str.format('cool %s', string)
- |> print($);
+main() |> print($);
+main() |> main2($) |> print($);