Exemple #1
0
 public void RegisterPunctuation(params string[] symbols)
 {
     foreach (string symbol in symbols)
     {
         SymbolTerminal term = Symbol(symbol);
         term.SetOption(TermOptions.IsPunctuation);
     }
 }
Exemple #2
0
 public Token(Terminal term, SourceLocation location, string text, object value)
 {
     SetTerminal(term);
     this.AsSymbol = term as SymbolTerminal;
     Location      = location;
     Text          = text;
     SetValue(value);
 }
Exemple #3
0
        public void RegisterBracePair(string openBrace, string closeBrace)
        {
            SymbolTerminal openS  = Symbol(openBrace);
            SymbolTerminal closeS = Symbol(closeBrace);

            openS.SetOption(TermOptions.IsOpenBrace);
            openS.IsPairFor = closeS;
            closeS.SetOption(TermOptions.IsCloseBrace);
            closeS.IsPairFor = openS;
        }
Exemple #4
0
 public void RegisterOperators(int precedence, Associativity associativity, params string[] opSymbols)
 {
     foreach (string op in opSymbols)
     {
         SymbolTerminal opSymbol = Symbol(op);
         opSymbol.SetOption(TermOptions.IsOperator);
         if (!UsePrecedenceRestricted)
         {
             opSymbol.SetOption(TermOptions.UsePrecedence);
         }
         opSymbol.Precedence    = precedence;
         opSymbol.Associativity = associativity;
     }
 }//method
Exemple #5
0
        public SymbolTerminal Symbol(string symbol, string name)
        {
            SymbolTerminal term;

            if (SymbolTerms.TryGetValue(symbol, out term))
            {
                //update name if it was specified now and not before
                if (string.IsNullOrEmpty(term.Name) && !string.IsNullOrEmpty(name))
                {
                    term.Name = name;
                }
                return(term);
            }
            //create new term
            if (!CaseSensitive)
            {
                symbol = symbol.ToLower();
            }
            string.Intern(symbol);
            term = new SymbolTerminal(symbol, name);
            SymbolTerms[symbol] = term;
            return(term);
        }