Ejemplo n.º 1
0
        void TestStage1Core(string text, LNode expected)
        {
            var   lexer     = ParsingService.Default.Tokenize(text, ConsoleMessageSink.Value);
            var   treeified = new TokensToTree(lexer, true);
            var   tokens    = treeified.Buffered();
            var   parser    = new StageOneParser(tokens, lexer.SourceFile, ConsoleMessageSink.Value);
            LNode result    = parser.Parse();

            AreEqual(expected, result);
        }
Ejemplo n.º 2
0
 private static LNode ParseStmtInRule(LNode stmt, IMessageSink sink)
 {
     if (stmt.Value is TokenTree)
     {
         return(StageOneParser.ParseTokenTree((TokenTree)stmt.Value, sink, stmt));
     }
     else
     {
         return(F.Braces(stmt));
     }
 }
Ejemplo n.º 3
0
 public static LNode Parse(IListSource <Token> tokenTree, ISourceFile file, IMessageSink messages)
 {
     if (_parser == null)
     {
         _parser = new StageOneParser(tokenTree, file, messages);
     }
     else
     {
         _parser.Reset(tokenTree, file);
         _parser.ErrorSink = messages;
     }
     return(_parser.Parse());
 }
Ejemplo n.º 4
0
        private static LNode ParseRuleBody(LNode ruleBody, IMessageSink sink)
        {
            TokenTree ruleTokens;

            if ((ruleTokens = ruleBody.Value as TokenTree) == null && !ruleBody.Calls(S.Braces))
            {
                return(null);
            }

            if (ruleTokens != null)
            {
                return(StageOneParser.ParseTokenTree(ruleTokens, sink, ruleBody));
            }
            else
            {
                if (ruleBody.Args.Any(stmt => stmt.Value is TokenTree))
                {
                    ruleBody = ruleBody.With(S.Tuple, ruleBody.Args.SmartSelect(stmt => ParseStmtInRule(stmt, sink)));
                }
            }
            return(ruleBody);
        }
Ejemplo n.º 5
0
 public static LNode ParseTokenTree(TokenTree tokens, IMessageSink sink, LNode basis)
 {
     return(StageOneParser.Parse(tokens, tokens.File, sink));
 }
Ejemplo n.º 6
0
		void TestStage1Core(string text, LNode expected)
		{
			var lexer = ParsingService.Default.Tokenize(text, ConsoleMessageSink.Value);
			var treeified = new TokensToTree(lexer, true);
			var tokens = treeified.Buffered();
			var parser = new StageOneParser(tokens, lexer.SourceFile, ConsoleMessageSink.Value);
			LNode result = parser.Parse();
			AreEqual(expected, result);
		}