本文整理汇总了C#中NVelocity.Runtime.Parser.Token类的典型用法代码示例。如果您正苦于以下问题:C# Token类的具体用法?C# Token怎么用?C# Token使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Token类属于NVelocity.Runtime.Parser命名空间,在下文中一共展示了Token类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseException
/// <summary> This constructor is used by the method "generateParseException"
/// in the generated parser. Calling this constructor generates
/// a new object of this type with the fields "currentToken",
/// "expectedTokenSequences", and "tokenImage" set. The boolean
/// flag "specialConstructor" is also set to true to indicate that
/// this constructor was used to create this object.
/// This constructor calls its super class with the empty string
/// to force the "toString" method of parent class "Throwable" to
/// print the error message in the form:
/// ParseException: <result of getMessage>
/// </summary>
public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal)
: base(string.Empty)
{
specialConstructor = true;
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
}
示例2: Directive
/// <summary> Supports the Pluggable Directives
/// #foo( arg+ )
/// </summary>
public SimpleNode Directive()
{
ASTDirective directiveNode = new ASTDirective(this, ParserTreeConstants.DIRECTIVE);
bool isNodeScopeOpen = true;
nodeTree.OpenNodeScope(directiveNode);
Token token;
Directive directive;
bool doItNow = false;
try
{
/*
* note that if we were escaped, that is now handled by
* EscapedDirective()
*/
token = ConsumeToken(ParserConstants.WORD);
String directiveName = token.Image.Substring(1);
directive = directives.Create(directiveName, directiveStack);
Debug.Assert(directiveNode != null);
directiveNode.Directive = directive;
/*
* Velocimacro support : if the directive is macro directive
* then set the flag so after the block parsing, we add the VM
* right then. (So available if used w/in the current template )
*/
if (directiveName.Equals("macro"))
{
doItNow = true;
}
/*
* set the directive name from here. No reason for the thing to know
* about parser tokens
*/
directiveNode.DirectiveName = directiveName;
DirectiveType directiveType;
if (directive == null)
{
// if null, then not a real directive, but maybe a Velocimacro
//d = (Directive) runtimeServices.getVelocimacro( directiveName, currentTemplateName );
// TODO: adding a null check since RuntimeServices is not finished
// since the parser can be created without RuntimeServices - this may actually be needed here and in the orgiginal source as well.
if (runtimeServices != null)
{
if (!runtimeServices.IsVelocimacro(directiveName, currentTemplateName))
{
token_source.StateStackPop();
token_source.inDirective = false;
if (true)
return directiveNode;
}
}
/*
* Currently, all VMs are LINE directives
*/
directiveType = DirectiveType.LINE;
}
else
{
directiveType = directive.Type;
}
/*
* now, switch us out of PRE_DIRECTIVE
*/
token_source.SwitchTo(ParserConstants.DIRECTIVE);
ConsumeWhiteSpaces();
if (directive != null && !directive.AcceptParams)
{
int curToken = GetCurrentTokenKind();
if (curToken == ParserConstants.NEWLINE)
{
ConsumeToken(ParserConstants.NEWLINE);
}
else
{
throw new ParseException(
"Foreach directives must be the only items on the line (comments or contents are not allowed)");
}
}
if (directive == null || directive.AcceptParams)
//.........这里部分代码省略.........
示例3: ScanToken
private bool ScanToken(int kind)
{
if (jj_scanpos == jj_lastpos)
{
jj_la--;
if (jj_scanpos.Next == null)
{
jj_lastpos = jj_scanpos = jj_scanpos.Next = token_source.NextToken;
}
else
{
jj_lastpos = jj_scanpos = jj_scanpos.Next;
}
}
else
{
jj_scanpos = jj_scanpos.Next;
}
if (jj_rescan)
{
int i = 0;
Token tok = token;
while(tok != null && tok != jj_scanpos)
{
i++;
tok = tok.Next;
}
if (tok != null)
{
AddErrorToken(kind, i);
}
}
return (jj_scanpos.Kind != kind);
}
示例4: ReInit
public void ReInit(ParserTokenManager tm)
{
token_source = tm;
token = new Token();
jj_ntk_Renamed_Field = -1;
nodeTree.Reset();
jj_gen = 0;
for(int i = 0; i < 53; i++)
jj_la1[i] = -1;
for(int i = 0; i < callsArray.Length; i++)
callsArray[i] = new Calls();
}
示例5: jj_3R_60
private bool jj_3R_60()
{
Token xsp = jj_scanpos;
if (jj_3R_50(jj_3R_81()))
{
jj_scanpos = xsp;
if (jj_3R_50(jj_3R_82()))
return true;
if (ToRefactor1())
return false;
}
else if (ToRefactor1())
return false;
return false;
}
示例6: jj_3R_86
private bool jj_3R_86()
{
if (jj_3R_89())
return true;
if (ToRefactor1())
return false;
while(true)
{
Token xsp = jj_scanpos;
if (jj_3R_90())
{
jj_scanpos = xsp;
break;
}
if (ToRefactor1())
return false;
}
return false;
}
示例7: jj_3R_19
private bool jj_3R_19()
{
Token xsp;
xsp = jj_scanpos;
if (jj_3R_38())
{
jj_scanpos = xsp;
if (jj_3R_39())
return true;
if (ToRefactor1())
return false;
}
else if (ToRefactor1())
return false;
return false;
}
示例8: jj_3R_38
private bool jj_3R_38()
{
if (ScanToken(ParserConstants.IDENTIFIER))
return true;
if (ToRefactor1())
return false;
while(true)
{
Token xsp = jj_scanpos;
if (jj_3_7())
{
jj_scanpos = xsp;
break;
}
if (ToRefactor1())
return false;
}
return false;
}
示例9: jj_3_7
private bool jj_3_7()
{
if (ScanToken(ParserConstants.DOT))
return true;
if (ToRefactor1())
return false;
Token xsp = jj_scanpos;
if (jj_3R_50(jj_3R_29()))
{
jj_scanpos = xsp;
if (jj_3R_50(jj_3R_41()))
return true;
if (ToRefactor1())
return false;
}
else if (ToRefactor1())
return false;
return false;
}
示例10: TokenLexicalActions
private void TokenLexicalActions(Token matchedToken)
{
switch(jjmatchedKind)
{
case 5:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
if (!inComment)
lparen++;
/*
* If in REFERENCE and we have seen the dot, then move
* to REFMOD2 -> Modifier()
*/
if (curLexState == REFMODIFIER)
SwitchTo(REFMOD2);
break;
case 6:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
RPARENHandler();
break;
case 7:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
/*
* need to simply switch back to REFERENCE, not drop down the stack
* because we can (infinitely) chain, ala
* $foo.bar().blargh().woogie().doogie()
*/
SwitchTo(REFERENCE);
break;
case 9:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
if (! inComment)
{
inDirective = true;
if (debugPrint)
Console.Out.Write("#set : going to {0}", DIRECTIVE);
StateStackPush();
inSet = true;
SwitchTo(DIRECTIVE);
}
break;
case 19:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
inComment = false;
StateStackPop();
break;
case 20:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
inComment = false;
StateStackPop();
break;
case 21:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
inComment = false;
StateStackPop();
break;
case 24:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
/*
* - if we are in DIRECTIVE and haven't seen ( yet, then also drop out.
* don't forget to account for the beloved yet wierd #set
* - finally, if we are in REFMOD2 (remember : $foo.bar( ) then " is ok!
*/
if (curLexState == DIRECTIVE && !inSet && lparen == 0)
StateStackPop();
break;
case 27:
if (image == null)
image = new StringBuilder(new String(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1))));
else
image.Append(input_stream.GetSuffix(jjimageLen + (jjmatchedPos + 1)));
//.........这里部分代码省略.........
示例11: jj_3R_90
private bool jj_3R_90()
{
Token xsp = jj_scanpos;
if (jj_3R_100(ParserConstants.LOGICAL_EQUALS, jj_3R_89()))
{
jj_scanpos = xsp;
if (jj_3R_100(ParserConstants.LOGICAL_NOT_EQUALS, jj_3R_89()))
return true;
if (ToRefactor1())
return false;
}
else if (ToRefactor1())
return false;
return false;
}
示例12: jj_3R_57
private bool jj_3R_57()
{
if (ScanToken(ParserConstants.LBRACKET))
return true;
if (ToRefactor1())
return false;
Token xsp = jj_scanpos;
if (jj_3R_77())
jj_scanpos = xsp;
else if (ToRefactor1())
return false;
if (ScanToken(ParserConstants.RBRACKET))
return true;
if (ToRefactor1())
return false;
return false;
}
示例13: jj_3R_29
private bool jj_3R_29()
{
if (jj_3R_41())
return true;
if (ToRefactor1())
return false;
if (ScanToken(ParserConstants.LPAREN))
return true;
if (ToRefactor1())
return false;
Token xsp = jj_scanpos;
if (jj_3R_42())
jj_scanpos = xsp;
else if (ToRefactor1())
return false;
if (ScanToken(ParserConstants.REFMOD2_RPAREN))
return true;
if (ToRefactor1())
return false;
return false;
}
示例14: jj_3R_82
private bool jj_3R_82()
{
if (jj_3R_84())
return true;
if (ToRefactor1())
return false;
while(true)
{
Token xsp = jj_scanpos;
if (jj_3R_100(ParserConstants.LOGICAL_OR, jj_3R_84()))
{
jj_scanpos = xsp;
break;
}
if (ToRefactor1())
return false;
}
return false;
}
示例15: jj_3_11
private bool jj_3_11()
{
Token xsp = jj_scanpos;
if (jj_3R_52())
jj_scanpos = xsp;
else if (ToRefactor1())
return false;
if (ScanToken(ParserConstants.LOGICAL_NOT))
return true;
if (ToRefactor1())
return false;
if (jj_3R_33())
return true;
if (ToRefactor1())
return false;
return false;
}