diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf48550 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# MParser + +A parser for MATLAB language. + +A single solution contains the following projects: + +* **Parser** contains the main lexing & parsing code. The main functionality +is taking a piece of text and parsing it into an abstract syntax tree (AST). +You can parse a whole .m file as well as one expression. +* **Parser.Tests** contains some tests for the parsing code. For example, +`ThereAndBackAgain.TestEverything()` parses all the files in MATLAB's +toolbox folder (you'll need a MATLAB installation to do this) and checks +that the text constructed from the resulting ASTs is the same as input text. +* **Semantics** contains some attempts at the next step: inferring semantics +of the code from ASTs. Examples may include tracking variable usage, +external function calls, etc. +* **SyntaxGenerator** is a stand-alone console program that generates a part +of parsing code (mostly class definitions for syntax nodes) from a simple XML. +We use it to avoid writing tons of boilerplate code by hand. +* **ConsoleDemo** is a console project used to play with parsing, print the +resulting ASTs (possibly with syntax highlighting), etc. + +The parser architecture is inspired by Microsoft's +[Roslyn](https://github.com/dotnet/roslyn) compiler for C#. Studying Roslyn +source code is a great way to learn about lexers, parsers, and all other +parts of a compiler. diff --git a/Solution.sln b/Solution.sln index f1333ca..6cd4da8 100644 --- a/Solution.sln +++ b/Solution.sln @@ -11,7 +11,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Parser.Tests", "Parser.Test EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SyntaxGenerator", "SyntaxGenerator\SyntaxGenerator.csproj", "{03487753-C1F5-4753-B576-593294ED86D1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Semantics", "Semantics\Semantics.csproj", "{4595633B-7F9A-4771-B348-F12BB9DD7ABC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Semantics", "Semantics\Semantics.csproj", "{4595633B-7F9A-4771-B348-F12BB9DD7ABC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5D38DE2B-50D4-4F66-A8C1-08D9191AD6BE}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution