示例#1
0
        private static SyntaxTree Parse(SourceText sourceText, Func<UnityParser, SyntaxNode> parseFunc)
        {
            var lexer = new UnityLexer(sourceText);
            var parser = new UnityParser(lexer);

            var result = new SyntaxTree(sourceText,
                syntaxTree => parseFunc(parser));

            Debug.WriteLine(DateTime.Now + " - Finished parsing");

            return result;
        }
示例#2
0
        public static IReadOnlyList<SyntaxToken> ParseAllTokens(SourceText sourceText)
        {
            var tokens = new List<SyntaxToken>();

            var lexer = new UnityLexer(sourceText);
            SyntaxToken token;
            do
            {
                tokens.Add(token = lexer.Lex());
            } while (token.Kind != SyntaxKind.EndOfFileToken);

            return tokens;
        }
示例#3
0
 public UnityParser(UnityLexer lexer)
 {
     _lexer = lexer;
 }