本文整理汇总了C#中ParseNode类的典型用法代码示例。如果您正苦于以下问题:C# ParseNode类的具体用法?C# ParseNode怎么用?C# ParseNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseNode类属于命名空间,在下文中一共展示了ParseNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DynamicFunction
public DynamicFunction(string name, ParseNode node, Variables args, int minParameters = 0, int maxParameters = 0)
{
Node = node;
Arguments = args;
MinParameters = minParameters;
MaxParameters = maxParameters;
}
开发者ID:ErikBehar,项目名称:sequencer,代码行数:7,代码来源:Function.cs
示例2: Compile
public CodeStream Compile(ParseNode node)
{
var child = Push(node);
Code += Compiler(child);
return Code;
}
开发者ID:andy-uq,项目名称:TinyOS,代码行数:7,代码来源:CompilerContext.cs
示例3: OutputDeclarationContent
public void OutputDeclarationContent(ParseNode node)
{
Assert(node.RuleName == "declaration_content");
string s = node.Aggregate("content: ", OutputChild);
WriteLine(s);
}
开发者ID:andy-uq,项目名称:TinyOS,代码行数:7,代码来源:CppStructuralOutputAsXml.cs
示例4: OutputDeclaration
public void OutputDeclaration(ParseNode node, string indent)
{
if (node.RuleName == "declaration")
{
Assert(node.Count == 1);
node = node[0];
Assert(node.Count >= 2);
Assert(node[0].RuleName == "comment_set");
OutputPrefixComment(node[0], indent);
switch (node[1].RuleName)
{
case "pp_directive":
WriteLine("pp_directive: " + node[1]);
break;
case "declaration_content":
OutputSuffixComment(node[3], indent);
OutputDeclarationContent(node[1]);
break;
case "semicolon":
WriteLine("empty declaration");
break;
default:
throw new Exception("Unrecognized kind of declaration");
}
}
foreach (ParseNode child in node)
OutputDeclaration(child, indent + " ");
}
开发者ID:andy-uq,项目名称:TinyOS,代码行数:33,代码来源:CppStructuralOutputAsXml.cs
示例5: 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);
}
开发者ID:LucasPeacecraft,项目名称:rawr,代码行数:27,代码来源:StateDescriptionParser.cs
示例6: 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
开发者ID:hvacengi,项目名称:TinyPG,代码行数:26,代码来源:Parser.cs
示例7: 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);
}
开发者ID:MGramolini,项目名称:Trinity,代码行数:27,代码来源:Parser.cs
示例8: 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);
}
开发者ID:FarReachJason,项目名称:Target-Process-Plugins,代码行数:27,代码来源:Parser.cs
示例9: ParserState
/// <summary>
/// Constructs a parser state, that manages a pointer to the text.
/// </summary>
/// <param name="text"></param>
public ParserState(string text)
{
this.text = text;
ParseNode root = new ParseNode(null, null, text, 0);
root.Complete(text.Length);
nodes.Push(root);
}
开发者ID:gtpk,项目名称:cpp-ripper,代码行数:11,代码来源:ParseState.cs
示例10: 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);
}
开发者ID:ElasticRaven,项目名称:KOS,代码行数:29,代码来源:Parser.cs
示例11: 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);
}
开发者ID:MGramolini,项目名称:Trinity,代码行数:31,代码来源:Parser.cs
示例12: Expacc
private void Expacc()
{
_currentNode.AddChild(new ParseNode(ParseEnum.ExpressionAccent));
_currentNode = _currentNode.getChildren()[_currentNode.getChildren().Count - 1];
if (!_lex.EndOfInput)
{
if (_current is AddSub)
{
_currentNode.AddChild(new ParseNode(ParseEnum.Operator, _current.GetValue()));
_current = _lex.GetNextToken();
Term();
Expacc();
}
else if (_current is Equals)
{
_currentNode.AddChild(new ParseNode(ParseEnum.Equals));
_current = _lex.GetNextToken();
Expressie();
}
else
{
_currentNode.AddChild(new ParseNode(ParseEnum.Empty));
}
}
_currentNode = _currentNode.GetParent();
}
开发者ID:TIRKIN,项目名称:RDP,代码行数:26,代码来源:Parser.cs
示例13: WhenSenderAndProjectCompanyMatched
private WhenSenderAndProjectCompanyMatched(ParseNode clauseNode, IStorageRepository storage,
UserRepository userRepository)
{
_projectId = Int32.Parse(ClauseFactory.FindRecursive(TokenType.NUMBER, clauseNode).Token.Text);
_storage = storage;
_userRepository = userRepository;
}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:7,代码来源:WhenSenderAndProjectCompanyMatched.cs
示例14: VisitDirective
public void VisitDirective(ParseNode node)
{
NodeStartHousekeeping(node);
// For now, let the compiler decide if the compiler directive is in the wrong place,
// not the parser. Therefore the parser treats it like a normal statement and here in
// the compiler we'll decide per-directive which directives can go where:
ParseNode directiveNode = node.Nodes[0]; // a directive contains the exact directive node nested one step inside it.
if (directiveNode.Nodes.Count < 2)
throw new KOSCompileException(new LineCol(lastLine, lastColumn), "Kerboscript compiler directive ('@') without a keyword after it.");
switch (directiveNode.Nodes[1].Token.Type)
{
case TokenType.LAZYGLOBAL:
VisitLazyGlobalDirective(directiveNode);
break;
// There is room for expansion here if we want to add more compiler directives.
default:
throw new KOSCompileException(new LineCol(lastLine, lastColumn), "Kerboscript compiler directive @"+directiveNode.Nodes[1].Text+" is unknown.");
}
}
开发者ID:KSP-KOS,项目名称:KOS,代码行数:25,代码来源:Compiler.cs
示例15: 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
开发者ID:hvacengi,项目名称:TinyPG,代码行数:33,代码来源:Parser.cs
示例16: Parseand_expr
private void Parseand_expr(ParseNode parent)
{
Token tok;
ParseNode n;
ParseNode node = parent.CreateNode(scanner.GetToken(TokenType.and_expr), "and_expr");
parent.Nodes.Add(node);
Parsecompare_expr(node);
tok = scanner.LookAhead(TokenType.AND);
while (tok.Type == TokenType.AND)
{
tok = scanner.Scan(TokenType.AND);
n = node.CreateNode(tok, tok.ToString() );
node.Token.UpdateRange(tok);
node.Nodes.Add(n);
if (tok.Type != TokenType.AND) {
tree.Errors.Add(new ParseError("Unexpected token '" + tok.Text.Replace("\n", "") + "' found. Expected " + TokenType.AND.ToString(), 0x1001, tok));
return;
}
Parsecompare_expr(node);
tok = scanner.LookAhead(TokenType.AND);
}
parent.Token.UpdateRange(node.Token);
}
开发者ID:ElasticRaven,项目名称:KOS,代码行数:28,代码来源:Parser.cs
示例17: UserFunction
public UserFunction(ParseNode originalNode)
{
codePart = new CodePart();
functions = new Dictionary<int, UserFunctionCodeFragment>();
newFunctions = new List<UserFunctionCodeFragment>();
OriginalNode = originalNode;
}
开发者ID:Whitecaribou,项目名称:KOS,代码行数:7,代码来源:UserFunction.cs
示例18: 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);
}
开发者ID:zzattack,项目名称:smallprogressmeasures,代码行数:59,代码来源:Parser.cs
示例19: ThenClause
protected ThenClause(ParseNode clauseNode, ITpBus bus, IStorageRepository storage)
{
_bus = bus;
_storage = storage;
var projectIdNode = ClauseFactory.FindRecursive(TokenType.NUMBER, clauseNode);
_projectId = Int32.Parse(projectIdNode.Token.Text);
}
开发者ID:chenhualei,项目名称:Target-Process-Plugins,代码行数:8,代码来源:ThenClause.cs
示例20: ParserState
/// <summary>
/// Constructs a parser state, that manages a pointer to the text.
/// </summary>
/// <param name="text"></param>
public ParserState(string text)
{
CreateNodes = true;
_text = text;
var root = new ParseNode(null, null, text, 0);
root.Complete(text.Length);
_nodes.Push(root);
}
开发者ID:andy-uq,项目名称:TinyOS,代码行数:12,代码来源:ParseState.cs
注:本文中的ParseNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论