public EmitToken(Channel channel, string tokenType, bool isError) { if(channel == null) throw new ArgumentNullException(nameof(channel)); if(string.IsNullOrWhiteSpace(tokenType)) throw new ArgumentNullException(nameof(tokenType)); Channel = channel; TokenType = tokenType; IsError = isError; }
public void AddStates(IDictionary<Mode, State> modeMap, CodePointEquivalenceClasses equivalenceClasses, NFA<LexerAction> nfa, int priority, Channel defaultChannel) { var states = Expression.AddTo(nfa, equivalenceClasses); foreach(var mode in Modes) nfa.AddEpsilonTransition(modeMap[mode], states.Start); nfa.SetFinal(states.End); // Set Action nfa.SetData(states.End, new LexerAction(priority, GetValueAction(), GetModeActions(), GetEmitAction(defaultChannel), GetCodeAction())); }
private LexerSpec(string lexerName, string lexerNamespace, IEnumerable<RuleSpec> rules, IEnumerable<Channel> channels, Channel defaultChannel, IEnumerable<Mode> modes, Mode initialMode, bool hasBeenSimplified) { LexerName = lexerName; LexerNamespace = lexerNamespace; Rules = new RuleSpecs(rules); Channels = new HashSet<Channel>(channels); DefaultChannel = defaultChannel; Channels.Add(DefaultChannel); Modes = new HashSet<Mode>(modes); InitialMode = initialMode; Modes.Add(InitialMode); HasBeenSimplified = hasBeenSimplified; }
public LexerSpec(string lexerName, string lexerNamespace, IEnumerable<RuleSpec> rules, IEnumerable<Channel> channels, Channel defaultChannel, IEnumerable<Mode> modes, Mode initialMode) : this(lexerName, lexerNamespace, rules, channels, defaultChannel, modes, initialMode, false) { }
private LexerEmitAction GetEmitAction(Channel defaultChannel) { if(Commands.Contains(Command.More)) return LexerEmitAction.More; if(Commands.Contains(Command.Skip)) return LexerEmitAction.Skip; return LexerEmitAction.Token(Channel ?? defaultChannel, TokenType, Commands.Contains(Command.FlagError)); }
protected bool Equals(Channel other) { return string.Equals(Name, other.Name); }