public PonyToken(string text, PonyTokenType tokenType, int column, int row) { Text = text; TokenType = tokenType; Column = column; Row = row; }
public static PonyToken Create(int col, int row, PonyTokenType type) { return(new PonyToken(type, col, row)); }
public PonyToken(PonyTokenType tokenType, int column, int row) { TokenType = tokenType; Column = column; Row = row; }
//L $ @ { [ ] } % : ID Q LF NUM ( ) //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 private int getTokenMapping(PonyToken token) { PonyTokenType tokenType = token.TokenType; PonyTokenType examedToken; switch (tokenType) { case PonyTokenType.LITERAL: return(0); case PonyTokenType.LBRACE: builder.StartMappingStruct(token); context.Push(tokenType); return(3); case PonyTokenType.RBRACE: if (!context.TryPop(out examedToken) || examedToken != PonyTokenType.LBRACE) { return(-1); } builder.EndCurrentContext(); return(6); case PonyTokenType.LBRACKET: context.Push(tokenType); return(4); case PonyTokenType.RBRACKET: if (!context.TryPop(out examedToken) || examedToken != PonyTokenType.LBRACKET) { return(-1); } if (!context.TryPop(out examedToken) || examedToken != PonyTokenType.DOLLAR) { return(-1); } builder.EndCurrentContext(); return(5); case PonyTokenType.LPAREN: context.Push(tokenType); return(13); case PonyTokenType.RPAREN: if (!context.TryPop(out examedToken) || examedToken != PonyTokenType.LPAREN) { return(-1); } builder.EndCurrentContext(); return(14); case PonyTokenType.AT: return(2); case PonyTokenType.ID: return(9); case PonyTokenType.CRLF: if (currentState == 3 && currentState == 5) { if (!context.TryPeek(out examedToken) || examedToken != PonyTokenType.DOLLAR) { return(-1); } } return(11); case PonyTokenType.QUOTE: return(10); case PonyTokenType.COLON: return(8); case PonyTokenType.DOLLAR: if (currentState == 4) { if (!context.TryPop(out examedToken) || examedToken != PonyTokenType.DOLLAR) { return(-1); } builder.EndCurrentContext(); return(1); } context.Push(tokenType); return(1); case PonyTokenType.PERCENTAGE: if (currentState == 0 || currentState == 10) { if (!context.TryPop(out examedToken) || examedToken != PonyTokenType.PERCENTAGE) { return(-1); } builder.EndCurrentContext(); if (currentState == 10) { // if we transit from 10. then the prev end ctx is only // end the paragraph struct. But the TextStruct ctx not ended. // so we need end for one more time thus to ensure we leave the TextStruct completely. builder.EndCurrentContext(); } return(7); } builder.StartTextStructure(token); context.Push(tokenType); return(7); case PonyTokenType.NUMBER: return(12); default: return(-1); } }