ArcaneScript is a custom programming language developed to explore language design and interpretation. This project includes the development of both the ArcaneScript language and its online Runner.
This pull request addresses the issue where calling a declared function using the invoke syntax results in a syntax error. The changes implement proper function invocation handling, allowing functions to be called as standalone statements and used within expressions.
Changes
Updated ArcaneGrammar7.grm to explicitly allow function calls as statements
Modified FunctionInvocation.java to handle both expression and statement function calls
Updated ArcaneInterpreter.java to properly initialize and handle function invocations
Adjusted Expression.java to support function calls within expressions
Updated Statements.java to execute function invocations correctly
Implementation Details
ArcaneGrammar7.grm
Added a new rule to allow function calls as statements:
Description
This pull request addresses the issue where calling a declared function using the
invoke
syntax results in a syntax error. The changes implement proper function invocation handling, allowing functions to be called as standalone statements and used within expressions.Changes
ArcaneGrammar7.grm
to explicitly allow function calls as statementsFunctionInvocation.java
to handle both expression and statement function callsArcaneInterpreter.java
to properly initialize and handle function invocationsExpression.java
to support function calls within expressionsStatements.java
to execute function invocations correctlyImplementation Details
ArcaneGrammar7.grm
Added a new rule to allow function calls as statements:
FunctionInvocation.java
@ProcessRule
to handle both expression and statement function callsArcaneInterpreter.java
FunctionInvocation
instancesExpression.java
getValue()
method to handleFunctionInvocation
instancesStatements.java
execute()
method to properly handleFunctionInvocation
instancesTesting
Tested with the following ArcaneScript code:
Output
Confirmed that functions can now be called as statements and used within expressions without syntax errors.
Additional Notes
Checklist
Closes #4