Add basic project skeleton, with trivial interpreter in place #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is pretty much a straight copy of perlun/cslox@64da4fd, with the following adjustments made:
Rename the namespaces to Perlang.*
Split the project into three parts:
Perlang.Common
,Perlang.Interpreter
andPerlang.Parser
. The idea here is to think already at an early stage about making the scanning and parsing parts reusable from non-interpreting/compiling scenarios. For example, to built a VS Code language server; it makes a lot of sense to not force all use cases that want to inspect Perlang source code to reimplement the whole language parser over and over again.Fix the code generated by
scripts/generate_ast_classes.rb
feel a bit more natural in the C# world, by using properties instead of plain fields. Also fixed the visibility since the generated code will now be in a different namespace from the classes that consume it.Try to improve the error handling slightly. It's still far from perfect and this is probably one of the things that will be improved
on in the quite near future. Ideally,
ParseStatements()
andParseExpression()
would return not just the parsed statements/expression, but in case something goes wrong, the full list of parse errors should be available there. Nothing should be printed to stdout unless the consumer decides to print it.Extract a few interfaces like
IInterpreter
,IParseErrorHandler
etc. We are not using any IOC container yet and time will tell if this will be necessary or not.