Example #1
0
        public static void ACTION(TokenRewriteStream tokens, CommonTree t)
        {
            CommonTree parent = (CommonTree)t.Parent;
            int        ptype  = parent.Type;

            if (ptype == ANTLRParser.SCOPE ||  // we have special rules for these
                ptype == ANTLRParser.AMPERSAND)
            {
                return;
            }
            //Console.Out.WriteLine( "ACTION: " + t.Text );
            CommonTree root = (CommonTree)t.GetAncestor(ANTLRParser.RULE);

            if (root != null)
            {
                CommonTree rule = (CommonTree)root.GetChild(0);
                //Console.Out.WriteLine( "rule: " + rule );
                if (!char.IsUpper(rule.Text[0]))
                {
                    tokens.Delete(t.TokenStartIndex, t.TokenStopIndex);
                    KillTrailingNewline(tokens, t.token.TokenIndex);
                }
            }
        }
Example #2
0
 public static void ACTION( TokenRewriteStream tokens, CommonTree t )
 {
     CommonTree parent = (CommonTree)t.Parent;
     int ptype = parent.Type;
     if ( ptype == ANTLRParser.SCOPE || // we have special rules for these
          ptype == ANTLRParser.AMPERSAND )
     {
         return;
     }
     //Console.Out.WriteLine( "ACTION: " + t.Text );
     CommonTree root = (CommonTree)t.GetAncestor( ANTLRParser.RULE );
     if ( root != null )
     {
         CommonTree rule = (CommonTree)root.GetChild( 0 );
         //Console.Out.WriteLine( "rule: " + rule );
         if ( Rule.GetRuleType( rule.Text ) == RuleType.Parser )
         {
             tokens.Delete( t.TokenStartIndex, t.TokenStopIndex );
             KillTrailingNewline( tokens, t.Token.TokenIndex );
         }
     }
 }