I'd like to have an engine console similar to how Quake and the Valve engines provide.
Tasks
[X] history -> list all of the previously run commands.
[X] Hitting the up/down keys will toggle through the history of run commands.
[X] Multi-line commands
[x] Variable Declarations
[x] Expression Evaluation
[x] Statement Evaluation
[x] While Loops
[x] Function Declaration
[x] For Loops
[ ] Lexical Scope Resolution
[ ] commands -> Lists all commands.
[ ] grammar -> Prints out the grammar for the Terminal language.
[ ] help -> Prints a help message
[ ] help cmd_name -> Prints the help information for a specific command.
[ ] Class Declaration
[ ] Copy/Paste
Commands
commands -> Lists all commands.
help -> Prints a help message
help -> Prints the help information for a specific command.
history -> list all of the previously run commands.
close -> Closes the terminal.
quit -> Quits the app
stop -> stops the active simulation
start -> starts the active simulation if it's paused.
Nice to Haves
Autocomplete
Copy/Paste both ways.
Optionally save the output to a file.
Blinking cursor character.
Register commands anywhere in the codebase via a decorator.
Help for registered commands. help
Hitting the up/down keys will toggle through the history of run commands.
Multi-line commands with the input line automatically "tabbing over".
Questions
What's the user experience? Have a panel slide down so it can work in full-screen mode? Dedicated nested window. Dedicated separate window? To have a separate top-level window I might have to have a separate Python process.
If it's a panel, perhaps, slide down from the top, and have the cursor fixed at the bottom line. Then the output scrolls above it.
Implementation Thoughts
Naive Approach
Just split the string and use the String module to check for numbers. Then use a match statement and a factory pattern or command pattern to invoke things.
Write a Lexer and Parser
Take a look at Fowler's DSL book.
Options
Leverage ANTLR to generate a lexer and parser. This approach involves creating a grammar and then generating the parser code. The parser be responsible for building up an Abstract Syntax Tree in memory. I would then need to have something take the AST and execute a python function. I might be able to register "hooks" on the parser to run commands automatically in a similar fashion to XSLTs or SAX parsers.
Use the Lark Python module. This is designed to be embedded in an application and use a grammar to parse content. It can generate ASTs.
Lrparsing is a parser generator that uses Python to define grammars.
Ply is a Python module for defining lexers and parsers in Python code. Rather simplistic. This may be a good option for the console.
PlyPlus is a Python module that expands beyond the capabilities of Ply.
Pyleri another parser generator that defines rules using python code. A good choice for doing autocompletions.
Arpeggio module generates simple parse trees but supports the use of a visitor.
Canopy is a parser generator that can target python.
Parsimonious is a python PEG parser that uses a simplified EBNF notation. Designed for speed and low RAM usage.
pyPEG is a framework for parsing and composing text.
TatSu is another python parser generator.
Waxeye is a parser generator based on parsing expression grammars (PEGs). It supports C, Java, Javascript, Python, Ruby and Scheme. Very clean-looking grammars.
Use a Parser Combinator
Parser combinators enable creating a parser by combining different pattern-matching functions that are equivalent to grammar rules. They are considered best suited for simpler parsing needs.
The Parsy module might work if I want to just do this in regex.
Pyparsing is another option. However, it might not have good documentation.
I'd like to have an engine console similar to how Quake and the Valve engines provide.
Tasks
Commands
Nice to Haves
help
Questions
Implementation Thoughts
Naive Approach
Just split the string and use the String module to check for numbers. Then use a match statement and a factory pattern or command pattern to invoke things.
Write a Lexer and Parser
Take a look at Fowler's DSL book.
Options
Leverage ANTLR to generate a lexer and parser. This approach involves creating a grammar and then generating the parser code. The parser be responsible for building up an Abstract Syntax Tree in memory. I would then need to have something take the AST and execute a python function. I might be able to register "hooks" on the parser to run commands automatically in a similar fashion to XSLTs or SAX parsers.
Use the Lark Python module. This is designed to be embedded in an application and use a grammar to parse content. It can generate ASTs.
Lrparsing is a parser generator that uses Python to define grammars.
Ply is a Python module for defining lexers and parsers in Python code. Rather simplistic. This may be a good option for the console.
PlyPlus is a Python module that expands beyond the capabilities of Ply.
Pyleri another parser generator that defines rules using python code. A good choice for doing autocompletions.
Arpeggio module generates simple parse trees but supports the use of a visitor.
Canopy is a parser generator that can target python.
Parsimonious is a python PEG parser that uses a simplified EBNF notation. Designed for speed and low RAM usage.
pyPEG is a framework for parsing and composing text.
TatSu is another python parser generator.
Waxeye is a parser generator based on parsing expression grammars (PEGs). It supports C, Java, Javascript, Python, Ruby and Scheme. Very clean-looking grammars.
Use a Parser Combinator
Parser combinators enable creating a parser by combining different pattern-matching functions that are equivalent to grammar rules. They are considered best suited for simpler parsing needs.
Create a DSL