Esempio n. 1
0
 public void MarkPunctuation(params string[] symbols)
 {
     foreach (string symbol in symbols)
     {
         KeyTerm term = ToTerm(symbol);
         term.SetFlag(TermFlags.IsPunctuation | TermFlags.NoAstNode);
     }
 }
Esempio n. 2
0
 public Token(Terminal term, SourceLocation location, string text, object value)
 {
     SetTerminal(term);
     this.KeyTerm = term as KeyTerm;
     Location     = location;
     Text         = text;
     Value        = value;
 }
Esempio n. 3
0
 public void RegisterBracePair(string openBrace, string closeBrace) {
   KeyTerm openS = ToTerm(openBrace);
   KeyTerm closeS = ToTerm(closeBrace);
   openS.SetFlag(TermFlags.IsOpenBrace);
   openS.IsPairFor = closeS;
   closeS.SetFlag(TermFlags.IsCloseBrace);
   closeS.IsPairFor = openS;
 }
Esempio n. 4
0
 public void RegisterOperators(int precedence, Associativity associativity, params string[] opSymbols) {
   foreach (string op in opSymbols) {
     KeyTerm opSymbol = ToTerm(op);
     opSymbol.SetFlag(TermFlags.IsOperator);
     opSymbol.Precedence = precedence;
     opSymbol.Associativity = associativity;
   }
 }//method
Esempio n. 5
0
 public KeyTerm ToTerm(string text, string name) {
   KeyTerm term;
   if (KeyTerms.TryGetValue(text, 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)
     text = text.ToLower();
   string.Intern(text); 
   term = new KeyTerm(text, name);
   KeyTerms[text] = term;
   return term; 
 }
Esempio n. 6
0
 public CodeOutlineFilter(GrammarData grammarData, OutlineOptions options, KeyTerm continuationTerminal)
 {
     _grammar = grammarData.Grammar;
     _grammar.LanguageFlags |= LanguageFlags.EmitLineStartToken;
     Options = options;
     ContinuationTerminal = continuationTerminal;
     if (ContinuationTerminal != null)
     {
         if (!_grammar.NonGrammarTerminals.Contains(ContinuationTerminal))
         {
             grammarData.Language.Errors.Add(GrammarErrorLevel.Warning, null, Resources.ErrOutlineFilterContSymbol, ContinuationTerminal.Name);
         }
     }
     //"CodeOutlineFilter: line continuation symbol '{0}' should be added to Grammar.NonGrammarTerminals list.",
     _produceIndents = IsSet(OutlineOptions.ProduceIndents);
     _checkBraces    = IsSet(OutlineOptions.CheckBraces);
     _checkOperator  = IsSet(OutlineOptions.CheckOperator);
     Reset();
 }
Esempio n. 7
0
 protected KeyTerm ToTerm(string text, string name)
 {
     if (KeyTerms.TryGetValue(text, out KeyTerm 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)
     {
         text = text.ToLower(CultureInfo.InvariantCulture);
     }
     string.Intern(text);
     term           = new KeyTerm(text, name);
     KeyTerms[text] = term;
     return(term);
 }
Esempio n. 8
0
        public KeyTerm ToTerm(string termValue, string name)
        {
            KeyTerm term;

            if (KeyTerms.TryGetValue(termValue, 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)
            {
                termValue = termValue.ToLowerInvariant();
            }
            term = new KeyTerm(termValue, name);
            KeyTerms[termValue] = term;
            return(term);
        }