2020-07-14 13:44:37 +02:00
2020-07-14 11:52:27 +02:00
2020-07-14 13:44:37 +02:00
2020-07-07 22:26:41 +02:00
2020-07-14 13:44:37 +02:00
2019-04-10 22:10:03 +02:00
2018-02-16 10:41:09 +01:00
2018-10-07 11:47:56 +02:00
2018-10-07 11:40:06 +02:00

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 compiler for C#. Studying Roslyn source code is a great way to learn about lexers, parsers, and all other parts of a compiler.

Description
A parser for MATLAB language
Readme 382 KiB
Languages
C# 100%