Right now, the current flowchart of the parser is, basically:
for token in source:
if token is name_definition:
if token is keyword:
parse_keyword
else:
parse_attribution_or_function_call
if token is open_brace:
add_simple_container
if token is close_brace:
close_current_container
if token is not new_line:
exception
This way, each line must be: either a special statement (like export, include, using, for, while, ...), or a variable attribution, or a function call.
To create a simple interactive console, this gets really tricky since plain resultors in a line (e.g. 3 + 5 - 2
are invalid). There is, actually, a workaround which almost fixes this (9c9a771), but it's not working when the line starts with a name definition (e.g. a variable name or a function call). In other words: "j = 5 + 3" is valid since the flowchart already parses it, but simply "j", for printing it in interactive mode, does not works, since the flowchart would then try to parse an attribution operator or a open parenthese for a function call.
Problem: it's necessary to make the parser work with resultors directly. In practice: move variable attribution to inside readResultor(), and then try to figure out what to do with the parsed resultor. For example, create an ExecutableResultor component or something like this, and then do interactive mode checking inside the executor. Interactive mode would print the resolved resultor, while normal mode would simply resolve the resultor. In interactive mode, it would be a good idea to not change the executor's result value to the last resultor's value, otherwise the 'return' keyword would be useless.
Advantages:
- simpler parser's flowchart
- attributions can be embed as resultors (e.g.
println(i = 3 + 5)
would print 8)
- interactive mode fully working
Disadvantages:
- readResultor() bloated of code