public void MarkPunctuation(params string[] symbols) { foreach (string symbol in symbols) { KeyTerm term = ToTerm(symbol); term.SetFlag(TermFlags.IsPunctuation | TermFlags.NoAstNode); } }
public Token(Terminal term, SourceLocation location, string text, object value) { SetTerminal(term); this.KeyTerm = term as KeyTerm; Location = location; Text = text; Value = value; }
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; }
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
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; }
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(); }
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); }
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); }