public static void addregexpr(TokenProduction p)
 {
     int ii;
     CSharpCCGlobals.rexprlist.Add(p);
     if (Options.getUserTokenManager()) {
         if (p.LexStates == null ||
             p.LexStates.Length != 1 ||
             !p.LexStates[0].Equals("DEFAULT")) {
             CSharpCCErrors.Warning(p, "Ignoring lexical state specifications since option " +
                                       "USER_TOKEN_MANAGER has been set to true.");
         }
     }
     if (p.LexStates == null) {
         return;
     }
     for (int i = 0; i < p.LexStates.Length; i++) {
         for (int j = 0; j < i; j++) {
             if (p.LexStates[i].Equals(p.LexStates[j])) {
                 CSharpCCErrors.ParseError(p, "Multiple occurrence of \"" + p.LexStates[i] + "\" in lexical state list.");
             }
         }
         if (!CSharpCCGlobals.lexstate_S2I.ContainsKey(p.LexStates[i])) {
             ii = nextFreeLexState++;
             CSharpCCGlobals.lexstate_S2I[p.LexStates[i]] = ii;
             CSharpCCGlobals.lexstate_I2S[ii] = p.LexStates[i];
             CSharpCCGlobals.simple_tokens_table[p.LexStates[i]] = new Dictionary<string, IDictionary<string, RegularExpression>>();
         }
     }
 }
 public static void add_inline_regexpr(RegularExpression r)
 {
     if (!(r is REndOfFile)) {
         TokenProduction p = new TokenProduction();
         p.IsExplicit = false;
         p.LexStates = new String[] {"DEFAULT"};
         p.Kind = TokenProduction.TOKEN;
         RegExprSpec res = new RegExprSpec();
         res.RegularExpression = r;
         res.RegularExpression.TokenProductionContext = p;
         res.Action = new Action();
         res.NextState = null;
         res.NextStateToken = null;
         p.RegexSpecs.Add(res);
         CSharpCCGlobals.rexprlist.Add(p);
     }
 }
Esempio n. 3
0
 public static void add_inline_regexpr(RegularExpression r)
 {
     if (!(r is REndOfFile))
     {
         TokenProduction p = new TokenProduction();
         p.IsExplicit = false;
         p.LexStates  = new String[] { "DEFAULT" };
         p.Kind       = TokenProduction.TOKEN;
         RegExprSpec res = new RegExprSpec();
         res.RegularExpression = r;
         res.RegularExpression.TokenProductionContext = p;
         res.Action         = new Action();
         res.NextState      = null;
         res.NextStateToken = null;
         p.RegexSpecs.Add(res);
         CSharpCCGlobals.rexprlist.Add(p);
     }
 }
Esempio n. 4
0
        public static void addregexpr(TokenProduction p)
        {
            int ii;

            CSharpCCGlobals.rexprlist.Add(p);
            if (Options.getUserTokenManager())
            {
                if (p.LexStates == null ||
                    p.LexStates.Length != 1 ||
                    !p.LexStates[0].Equals("DEFAULT"))
                {
                    CSharpCCErrors.Warning(p, "Ignoring lexical state specifications since option " +
                                           "USER_TOKEN_MANAGER has been set to true.");
                }
            }
            if (p.LexStates == null)
            {
                return;
            }
            for (int i = 0; i < p.LexStates.Length; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    if (p.LexStates[i].Equals(p.LexStates[j]))
                    {
                        CSharpCCErrors.ParseError(p, "Multiple occurrence of \"" + p.LexStates[i] + "\" in lexical state list.");
                    }
                }
                if (!CSharpCCGlobals.lexstate_S2I.ContainsKey(p.LexStates[i]))
                {
                    ii = nextFreeLexState++;
                    CSharpCCGlobals.lexstate_S2I[p.LexStates[i]]        = ii;
                    CSharpCCGlobals.lexstate_I2S[ii]                    = p.LexStates[i];
                    CSharpCCGlobals.simple_tokens_table[p.LexStates[i]] = new Dictionary <string, IDictionary <string, RegularExpression> >();
                }
            }
        }