File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
ownlang-parser/src/main/java/com/annimon/ownlang/parser Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ private Statement statement() {
160
160
return classDeclaration ();
161
161
}
162
162
if (lookMatch (0 , TokenType .WORD ) && lookMatch (1 , TokenType .LPAREN )) {
163
- return new ExprStatement ( functionChain ( qualifiedName ()) );
163
+ return functionCallStatement ( );
164
164
}
165
165
return assignmentStatement ();
166
166
}
@@ -321,6 +321,12 @@ private Statement statementBody() {
321
321
return statementOrBlock ();
322
322
}
323
323
324
+ private ExprStatement functionCallStatement () {
325
+ return new ExprStatement (
326
+ functionChain (new ValueExpression (consume (TokenType .WORD ).text ()))
327
+ );
328
+ }
329
+
324
330
private Expression functionChain (Expression qualifiedNameExpr ) {
325
331
// f1()()() || f1().f2().f3() || f1().key
326
332
final Expression expr = function (qualifiedNameExpr );
Original file line number Diff line number Diff line change @@ -45,15 +45,11 @@ public Value eval() {
45
45
}
46
46
47
47
private Function consumeFunction (Expression expr ) {
48
- try {
49
- final Value value = expr .eval ();
50
- if (value .type () == Types .FUNCTION ) {
51
- return ((FunctionValue ) value ).getValue ();
52
- }
53
- return getFunction (value .asString ());
54
- } catch (VariableDoesNotExistsException ex ) {
55
- return getFunction (ex .getVariable ());
48
+ final Value value = expr .eval ();
49
+ if (value .type () == Types .FUNCTION ) {
50
+ return ((FunctionValue ) value ).getValue ();
56
51
}
52
+ return getFunction (value .asString ());
57
53
}
58
54
59
55
private Function getFunction (String key ) {
You can’t perform that action at this time.
0 commit comments