Beispiel #1
0
 private static LNode ParseStmtInRule(LNode stmt, IMessageSink sink)
 {
     if (stmt.Value is TokenTree)
     {
         return(StageOneParser.ParseTokenTree((TokenTree)stmt.Value, sink));
     }
     else
     {
         return(F.Braces(stmt));
     }
 }
Beispiel #2
0
        private static LNode ParseRuleBody(LNode ruleBody, IMessageSink sink)
        {
            TokenTree ruleTokens;

            // Expecting @[...] or {...}
            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);
        }