private ail.net.parser.AstNode LastChildAttr; // last child #endregion // data members #region ctor/dtor/finalizer public AstNode(int xi_type) { TypeAttr = xi_type; TokenAttr = null; ParentAttr = null; BrotherAttr = null; ChildAttr = null; LastChild = null; }
public LexAnalyzer(ail.net.parser.Token xi_token_class, ArrayList xi_errors) { ail.net.framework.Assert.NonNullReference(xi_token_class, "xi_token_class"); ail.net.framework.Assert.NonNullReference(xi_errors, "xi_errors"); TokenAttr = xi_token_class; LexemeModeAttr = ail.net.parser.LexAnalyzer.ELexemeMode.eCurrent; ErrorsAttr = xi_errors; TmpTokenIdAttr = (int)ail.net.parser.Token.EType.eUnknown; HasBacktrackingAttr = true; }
public void AddFinalState(ail.net.parser.FsaState xi_state, ail.net.parser.Token xi_token) { ail.net.framework.Assert.NonNullReference(xi_state, "xi_state"); ail.net.framework.Assert.NonNullReference(xi_token, "xi_token"); if (!FinalStates.Contains(xi_state.Id)) { xi_state.Token = xi_token; FinalStates.Add(xi_state.Id, xi_state); } }
public override void HandleTerminal(ail.net.parser.AstNode xi_node, ail.net.parser.Token xi_token) { if (xi_token.Type == (int)ail.net.test.SssToken.EType.eN) { xi_node.Type = (int)ail.net.test.SssAstNode.EType.eSn; xi_node.Token = xi_token; } else if (xi_token.Type == (int)ail.net.test.SssToken.EType.ePlus) { xi_node.Type = (int)ail.net.test.SssAstNode.EType.eSp; xi_node.Token = xi_token; } }
public override void HandleError(object xi_item, ail.net.parser.Token xi_token, int [] xi_error_costs) { }
public override void HandleTerminal(ail.net.parser.AstNode xi_node, ail.net.parser.Token xi_token) { }
// error recovery public abstract void HandleError(object xi_item, ail.net.parser.Token xi_token, int [] xi_error_costs);
// terminal action public abstract void HandleTerminal(ail.net.parser.AstNode xi_node, ail.net.parser.Token xi_token);
public virtual void LookAheadLexeme(ref ail.net.parser.Token xo_token, int xi_lookahead, int xi_context) { }
public void AddToken(ail.net.parser.Fsa xi_fsa, string xi_token, int xi_token_type, int xi_escape_token_type, string xi_escape_predicate) { ail.net.framework.Assert.NonNullReference(xi_fsa, "xi_fsa"); ail.net.framework.Assert.NonEmptyString(xi_token, "xi_token"); ail.net.parser.FsaState q1 = null; if (xi_fsa.StartState != (object)null) { q1 = xi_fsa.AddState(); xi_fsa.AddTransition(xi_fsa.StartState, q1, ail.net.parser.FsaTransition.kEpsilonPredicate); } else { q1 = xi_fsa.AddState(); } ail.net.parser.FsaState eq = null; // escape state if (xi_escape_token_type != ail.net.parser.Token.kUndefinedEscapeTokenType) { eq = xi_fsa.AddState(); xi_fsa.AddTransition(eq, eq, xi_escape_predicate, ail.net.parser.FsaTransition.kMaxRankValue); ail.net.parser.Token token = (ail.net.parser.Token)Factory.Create(Token.GetType()); token.Type = xi_escape_token_type; token.Priority = ail.net.parser.LexAnalyzer.kEscapeTokenPriority; xi_fsa.AddFinalState(eq, token); } ail.net.parser.FsaState q_prev = q1; ail.net.parser.FsaState q_curr = q1; for (int i = 0; i < xi_token.Length; i++) { q_curr = xi_fsa.AddState(); ail.net.framework.Assert.NonNullReference(q_curr, "q_curr"); xi_fsa.AddTransition(q_prev, q_curr, ail.net.framework.CharPredicate.BuildAsciiCharPredicate(xi_token[i]), (char)xi_token[i]); if (i == xi_token.Length - 1) { ail.net.parser.Token token = (ail.net.parser.Token)Factory.Create(Token.GetType()); token.Type = xi_token_type; token.Priority = ail.net.parser.LexAnalyzer.kDefaultTokenPriority; xi_fsa.AddFinalState(q_curr, token); } else if (xi_escape_token_type != ail.net.parser.Token.kUndefinedEscapeTokenType) { ail.net.parser.Token token = (ail.net.parser.Token)Factory.Create(Token.GetType()); token.Type = xi_escape_token_type; token.Priority = ail.net.parser.LexAnalyzer.kEscapeTokenPriority; xi_fsa.AddFinalState(q_curr, token); } if (xi_escape_token_type != ail.net.parser.Token.kUndefinedEscapeTokenType) { xi_fsa.AddTransition(q_curr, eq, xi_escape_predicate, ail.net.parser.FsaTransition.kMaxRankValue); } q_prev = q_curr; } }