public bool Store(LexemType type, string content) { char character; LexemState state; if (content.Length > 0) { character = content[0]; if (!this.branches.TryGetValue(character, out state)) { state = new LexemState(); this.branches[character] = state; } return(state.Store(type, content.Substring(1))); } else if (this.type == LexemType.None) { this.type = type; return(true); } return(false); }
public bool Store(LexemType type, string content) { LexemState current; LexemState next; current = this; foreach (char character in content) { if (current.branches == null) { current.branches = new Dictionary <char, LexemState> (); } if (!current.branches.TryGetValue(character, out next)) { next = new LexemState(); current.branches[character] = next; } current = next; } if (current.type != LexemType.None) { return(false); } current.type = type; return(true); }
public bool Store(LexemType type, string content) { char character; LexemState state; if (content.Length > 0) { character = content[0]; if (!this.branches.TryGetValue (character, out state)) { state = new LexemState (); this.branches[character] = state; } return state.Store (type, content.Substring (1)); } else if (this.type == LexemType.None) { this.type = type; return true; } return false; }
public bool Store(LexemType type, string content) { LexemState current; LexemState next; current = this; foreach (char character in content) { if (character < LexemState.BRANCH_LIMIT) { if (current.branchesLow == null) { current.branchesLow = new LexemState[LexemState.BRANCH_LIMIT]; } next = current.branchesLow[character]; if (next == null) { next = new LexemState(); current.branchesLow[character] = next; } } else { if (current.branchesHigh == null) { current.branchesHigh = new Dictionary <char, LexemState> (); } if (!current.branchesHigh.TryGetValue(character, out next)) { next = new LexemState(); current.branchesHigh[character] = next; } } current = next; } if (current.type != LexemType.None) { return(false); } current.type = type; return(true); }
public Lexer(string blockBegin, string blockContinue, string blockEnd, char escape) { this.cursors = new Queue<LexemCursor> (); this.escape = escape; this.pending = new Queue<char> (); this.root = new LexemState (); if (!this.root.Store (LexemType.BlockBegin, blockBegin)) throw new ConfigException ("blockBegin", blockBegin, "block delimiter used twice"); if (!this.root.Store (LexemType.BlockContinue, blockContinue)) throw new ConfigException ("blockContinue", blockContinue, "block delimiter used twice"); if (!this.root.Store (LexemType.BlockEnd, blockEnd)) throw new ConfigException ("blockEnd", blockEnd, "block delimiter used twice"); }
public Lexer(string blockBegin, string blockContinue, string blockEnd, char escape) { this.cursors = new List <LexemCursor> (); this.escape = escape; this.pending = new Queue <char> (); this.root = new LexemState(); if (!this.root.Store(LexemType.BlockBegin, blockBegin)) { throw new ConfigException("blockBegin", blockBegin, "block delimiter used twice"); } if (!this.root.Store(LexemType.BlockContinue, blockContinue)) { throw new ConfigException("blockContinue", blockContinue, "block delimiter used twice"); } if (!this.root.Store(LexemType.BlockEnd, blockEnd)) { throw new ConfigException("blockEnd", blockEnd, "block delimiter used twice"); } }