예제 #1
0
 public void MarkPunctuation(params string[] symbols)
 {
     foreach (string symbol in symbols)
     {
         KeyTerm term = ToTerm(symbol);
         term.SetFlag(TermFlags.IsPunctuation | TermFlags.NoAstNode);
     }
 }
예제 #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;
 }
예제 #3
0
파일: Grammar.cs 프로젝트: joewan/xenko
 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;
 }
예제 #4
0
파일: Grammar.cs 프로젝트: joewan/xenko
 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
예제 #5
0
파일: Grammar.cs 프로젝트: joewan/xenko
 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; 
 }
예제 #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();
 }
예제 #7
0
파일: Grammar.cs 프로젝트: hozuki/irony-vs
 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);
 }
예제 #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);
        }