Venturecxx
Venturecxx copied to clipboard
Clean up parsing code
Enabled by (or noticed during?) f5683f157b4193be63e84a237f919c2889cda7da .
- [x] The whole
split_program
pattern is redundant, because it cycles through the parser's ability to parse multi-instruction streams anyway. - [ ]
split_instruction
in the parsers should be pretty useless; flush it? - [ ]
expression_index_to_text_index
in the parsers is looking pretty useless; flush it?
Entry points into parsing:
- Console calls ripl.execute_instruction or ripl.execute_instructions
- ripl.execute_instructions calls
- p.split_program
- p.parse_instruction
- then ripl.execute_parsed_instruction
- ripl.execute_instruction calls
- p.parse_instruction or
- ripl._ensure_parsed
- then ripl.execute_parsed_instruction
- ripl.execute_program{,_from_file} calls
- ripl.parse_program which
- does the horrible thing with the comments
- calls ripl.split_program
- calls ripl._ensure_parsed
- ripl.execute_parsed_program
- which special-cases "load" instructions!?
- ripl.parse_program which
- ripl._ensure_parsed bottoms out in
- p.parse_expression
- p.parse_number
The error reporting also interacts with the parser
- split_instruction is used for annotation (after the fact)
All of which bottom out in parse_instructions (with various manipulations of the returned location dicts).
Please flush all the splitting crud!
Do I detect evidence of a splitting headache?
Yes -- standard remedy is to drink lots of water to flush it out.