本文整理汇总了C#中ParseNode.CreateNode方法的典型用法代码示例。如果您正苦于以下问题:C# ParseNode.CreateNode方法的具体用法?C# ParseNode.CreateNode怎么用?C# ParseNode.CreateNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseNode
的用法示例。
在下文中一共展示了ParseNode.CreateNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseStart
private void ParseStart(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.Start), "Start");
parent.Nodes.Add(node);
tok = scanner.LookAhead(TokenType.COMPLEMENT, TokenType.STATE, TokenType.BROPEN);
if (tok.Type == TokenType.COMPLEMENT
|| tok.Type == TokenType.STATE
|| tok.Type == TokenType.BROPEN)
{
ParseUnionExpr(node);
}
tok = scanner.Scan(TokenType.EOF);
if (tok.Type != TokenType.EOF)
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.EOF.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
parent.Token.UpdateRange(node.Token);
}
示例2: ParseStart
private void ParseStart(ParseNode parent) // NonTerminalSymbol: Start
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.Start), "Start");
parent.Nodes.Add(node);
// Concat Rule
do { // OneOrMore Rule
ParseAddExpr(node); // NonTerminal Rule: AddExpr
tok = scanner.LookAhead(TokenType.NUMBER, TokenType.BROPEN); // OneOrMore Rule
|| tok.Type == TokenType.NUMBER
|| tok.Type == TokenType.BROPEN); // OneOrMore Rule
// Concat Rule
tok = scanner.Scan(TokenType.EOF); // Terminal Rule: EOF
if (tok.Type != TokenType.EOF)
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.EOF.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
parent.Token.UpdateRange(node.Token);
} // NonTerminalSymbol: Start
示例3: ParseStart
private void ParseStart(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.Start), "Start");
parent.Nodes.Add(node);
tok = scanner.LookAhead(TokenType.VARIABLE, TokenType.STRING, TokenType.NUMBER, TokenType.BOOLEAN, TokenType.BROPEN);
if (tok.Type == TokenType.VARIABLE
|| tok.Type == TokenType.STRING
|| tok.Type == TokenType.NUMBER
|| tok.Type == TokenType.BOOLEAN
|| tok.Type == TokenType.BROPEN)
{
ParseExpr(node);
}
tok = scanner.Scan(TokenType.EOF);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.EOF) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.EOF.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
parent.Token.UpdateRange(node.Token);
}
示例4: ParseAddExpr
} // NonTerminalSymbol: Start
private void ParseAddExpr(ParseNode parent) // NonTerminalSymbol: AddExpr
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.AddExpr), "AddExpr");
parent.Nodes.Add(node);
// Concat Rule
ParseMultExpr(node); // NonTerminal Rule: MultExpr
// Concat Rule
tok = scanner.LookAhead(TokenType.PLUSMINUS); // ZeroOrMore Rule
while (tok.Type == TokenType.PLUSMINUS)
{
// Concat Rule
tok = scanner.Scan(TokenType.PLUSMINUS); // Terminal Rule: PLUSMINUS
if (tok.Type != TokenType.PLUSMINUS)
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.PLUSMINUS.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
// Concat Rule
ParseMultExpr(node); // NonTerminal Rule: MultExpr
tok = scanner.LookAhead(); // ZeroOrMore Rule
}
parent.Token.UpdateRange(node.Token);
} // NonTerminalSymbol: AddExpr
示例5: ParseSepExpr
private void ParseSepExpr(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.SepExpr), "SepExpr");
parent.Nodes.Add(node);
ParseOrExpr(node);
tok = scanner.LookAhead(TokenType.SEPARATOR);
while (tok.Type == TokenType.SEPARATOR)
{
tok = scanner.Scan(TokenType.SEPARATOR);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.SEPARATOR) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.SEPARATOR.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
ParseOrExpr(node);
tok = scanner.LookAhead(TokenType.SEPARATOR);
}
parent.Token.UpdateRange(node.Token);
}
示例6: ParseCompanyMatchedClause
private void ParseCompanyMatchedClause(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.CompanyMatchedClause), "CompanyMatchedClause");
parent.Nodes.Add(node);
tok = scanner.Scan(TokenType.CompanyMatchedKeyword);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.CompanyMatchedKeyword) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.CompanyMatchedKeyword.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
tok = scanner.Scan(TokenType.NUMBER);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.NUMBER) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.NUMBER.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
parent.Token.UpdateRange(node.Token);
}
示例7: Parseadd_stmt
private void Parseadd_stmt(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.add_stmt), "add_stmt");
parent.Nodes.Add(node);
tok = scanner.Scan(TokenType.ADD);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.ADD) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.ADD.ToString(), 0x1001, tok));
return;
}
Parseexpr(node);
tok = scanner.Scan(TokenType.EOI);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.EOI) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.EOI.ToString(), 0x1001, tok));
return;
}
parent.Token.UpdateRange(node.Token);
}
示例8: ParseNodeSpec
private void ParseNodeSpec(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.NodeSpec), "NodeSpec");
parent.Nodes.Add(node);
tok = scanner.Scan(TokenType.IDENTIFIER);
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.IDENTIFIER) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.IDENTIFIER.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
tok = scanner.Scan(TokenType.IDENTIFIER);
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.IDENTIFIER) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.IDENTIFIER.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
tok = scanner.Scan(TokenType.IDENTIFIER);
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.IDENTIFIER) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.IDENTIFIER.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
ParseSuccessors(node);
tok = scanner.LookAhead(TokenType.STRING);
if (tok.Type == TokenType.STRING) {
tok = scanner.Scan(TokenType.STRING);
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.STRING) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.STRING.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
}
tok = scanner.Scan(TokenType.SEMICOLON);
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.SEMICOLON) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.SEMICOLON.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
parent.Token.UpdateRange(node.Token);
}
示例9: ParseArithmeticOperator
private void ParseArithmeticOperator(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.ArithmeticOperator), "ArithmeticOperator");
parent.Nodes.Add(node);
tok = scanner.LookAhead(TokenType.PLUS, TokenType.MINUS, TokenType.ASTERISK, TokenType.FSLASH, TokenType.PERCENT);
switch (tok.Type)
{
case TokenType.PLUS:
tok = scanner.Scan(TokenType.PLUS);
if (tok.Type != TokenType.PLUS)
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.PLUS.ToString(), 0x1001, tok.LinePos, tok.ColumnPos, tok.StartPos, tok.Length));
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
break;
case TokenType.MINUS:
tok = scanner.Scan(TokenType.MINUS);
if (tok.Type != TokenType.MINUS)
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.MINUS.ToString(), 0x1001, tok.LinePos, tok.ColumnPos, tok.StartPos, tok.Length));
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
break;
case TokenType.ASTERISK:
tok = scanner.Scan(TokenType.ASTERISK);
if (tok.Type != TokenType.ASTERISK)
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.ASTERISK.ToString(), 0x1001, tok.LinePos, tok.ColumnPos, tok.StartPos, tok.Length));
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
break;
case TokenType.FSLASH:
tok = scanner.Scan(TokenType.FSLASH);
if (tok.Type != TokenType.FSLASH)
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.FSLASH.ToString(), 0x1001, tok.LinePos, tok.ColumnPos, tok.StartPos, tok.Length));
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
break;
case TokenType.PERCENT:
tok = scanner.Scan(TokenType.PERCENT);
if (tok.Type != TokenType.PERCENT)
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.PERCENT.ToString(), 0x1001, tok.LinePos, tok.ColumnPos, tok.StartPos, tok.Length));
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
break;
default:
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found.", 0x0002, tok.LinePos, tok.ColumnPos, tok.StartPos, tok.Length));
break;
}
parent.Token.UpdateRange(node.Token);
}
示例10: ParseAdditiveExpression
// NonTerminalSymbol: AdditiveExpression
private void ParseAdditiveExpression(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.AdditiveExpression), "AdditiveExpression");
parent.Nodes.Add(node);
// Concat Rule
ParseMultiplicativeExpression(node); // NonTerminal Rule: MultiplicativeExpression
// Concat Rule
tok = scanner.LookAhead(TokenType.PLUS, TokenType.MINUS); // ZeroOrMore Rule
while (tok.Type == TokenType.PLUS
|| tok.Type == TokenType.MINUS)
{
// Concat Rule
tok = scanner.LookAhead(TokenType.PLUS, TokenType.MINUS); // Choice Rule
switch (tok.Type)
{ // Choice Rule
case TokenType.PLUS:
tok = scanner.Scan(TokenType.PLUS); // Terminal Rule: PLUS
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.PLUS)
{
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.PLUS.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
break;
case TokenType.MINUS:
tok = scanner.Scan(TokenType.MINUS); // Terminal Rule: MINUS
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.MINUS)
{
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.MINUS.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
break;
default:
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found.", 0x0002, 0, tok.StartPos, tok.StartPos, tok.Length));
break;
} // Choice Rule
// Concat Rule
ParseMultiplicativeExpression(node); // NonTerminal Rule: MultiplicativeExpression
tok = scanner.LookAhead(TokenType.PLUS, TokenType.MINUS); // ZeroOrMore Rule
}
parent.Token.UpdateRange(node.Token);
}
示例11: ParseExpr
private void ParseExpr(ParseNode parent)
{
//Token tok;
//ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.Expr), "Expr");
parent.Nodes.Add(node);
ParseSepExpr(node);
parent.Token.UpdateRange(node.Token);
}
示例12: ParseStart
private void ParseStart(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.Start), "Start");
parent.Nodes.Add(node);
tok = scanner.LookAhead(TokenType.Code, TokenType.Technique, TokenType.Sampler);
while (tok.Type == TokenType.Code
|| tok.Type == TokenType.Technique
|| tok.Type == TokenType.Sampler)
{
tok = scanner.LookAhead(TokenType.Code, TokenType.Technique, TokenType.Sampler);
switch (tok.Type)
{
case TokenType.Code:
tok = scanner.Scan(TokenType.Code);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.Code) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.Code.ToString(), 0x1001, tok));
return;
}
break;
case TokenType.Technique:
ParseTechnique_Declaration(node);
break;
case TokenType.Sampler:
ParseSampler_Declaration(node);
break;
default:
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found.", 0x0002, tok));
break;
}
tok = scanner.LookAhead(TokenType.Code, TokenType.Technique, TokenType.Sampler);
}
tok = scanner.Scan(TokenType.EndOfFile);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.EndOfFile) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.EndOfFile.ToString(), 0x1001, tok));
return;
}
parent.Token.UpdateRange(node.Token);
}
示例13: ParseStart
private void ParseStart(ParseNode parent) // NonTerminalSymbol: Start
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.Start), "Start");
parent.Nodes.Add(node);
// Concat Rule
tok = scanner.LookAhead(TokenType.Code, TokenType.Technique, TokenType.Sampler); // ZeroOrMore Rule
while (tok.Type == TokenType.Code
|| tok.Type == TokenType.Technique
|| tok.Type == TokenType.Sampler)
{
tok = scanner.LookAhead(TokenType.Code, TokenType.Technique, TokenType.Sampler); // Choice Rule
switch (tok.Type)
{ // Choice Rule
case TokenType.Code:
tok = scanner.Scan(TokenType.Code); // Terminal Rule: Code
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.Code) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.Code.ToString(), 0x1001, tok));
return;
}
break;
case TokenType.Technique:
ParseTechnique_Declaration(node); // NonTerminal Rule: Technique_Declaration
break;
case TokenType.Sampler:
ParseSampler_Declaration(node); // NonTerminal Rule: Sampler_Declaration
break;
default:
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected Code, Technique, or Sampler.", 0x0002, tok));
break;
} // Choice Rule
tok = scanner.LookAhead(TokenType.Code, TokenType.Technique, TokenType.Sampler); // ZeroOrMore Rule
}
// Concat Rule
tok = scanner.Scan(TokenType.EndOfFile); // Terminal Rule: EndOfFile
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.EndOfFile) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.EndOfFile.ToString(), 0x1001, tok));
return;
}
parent.Token.UpdateRange(node.Token);
} // NonTerminalSymbol: Start
示例14: ParseExpression
private void ParseExpression(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.Expression), "Expression");
parent.Nodes.Add(node);
ParseConditionalExpression(node);
parent.Token.UpdateRange(node.Token);
}
示例15: ParseAddExpr
private void ParseAddExpr(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.AddExpr), "AddExpr");
parent.Nodes.Add(node);
ParseMultExpr(node);
tok = scanner.LookAhead(TokenType.PLUS, TokenType.MINUS);
while (tok.Type == TokenType.PLUS
|| tok.Type == TokenType.MINUS)
{
tok = scanner.LookAhead(TokenType.PLUS, TokenType.MINUS);
switch (tok.Type)
{
case TokenType.PLUS:
tok = scanner.Scan(TokenType.PLUS);
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.PLUS)
{
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.PLUS.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
break;
case TokenType.MINUS:
tok = scanner.Scan(TokenType.MINUS);
n = node.CreateNode(tok, tok.ToString());
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.MINUS)
{
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.MINUS.ToString(), 0x1001, 0, tok.StartPos, tok.StartPos, tok.Length));
return;
}
break;
default:
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found.", 0x0002, 0, tok.StartPos, tok.StartPos, tok.Length));
break;
}
ParseMultExpr(node);
tok = scanner.LookAhead(TokenType.PLUS, TokenType.MINUS);
}
parent.Token.UpdateRange(node.Token);
}