Example #1
0
        public SyntaxTree Parse()
        {
            var lexer             = new Internal.MLexerGreen(_window);
            var lexerDiagnostics  = lexer.Diagnostics;
            var tokens            = lexer.ParseAll();
            var parser            = new Internal.MParserGreen(tokens, new Internal.SyntaxFactory());
            var green             = parser.ParseRoot();
            var parserDiagnostics = parser.Diagnostics;
            var totalDiagnostics  = new DiagnosticsBag(lexerDiagnostics.Concat(parserDiagnostics));
            var root = new RootSyntaxNode(green, 0);

            return(new SyntaxTree(root, totalDiagnostics));
        }
Example #2
0
 public SyntaxTree(RootSyntaxNode nullRoot, DiagnosticsBag diagnostics)
 {
     NullRoot    = nullRoot ?? throw new ArgumentNullException(nameof(nullRoot));
     Diagnostics = diagnostics ?? throw new ArgumentNullException(nameof(diagnostics));
 }