Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser<TIn,TOut>.Parse(code) Stack overflow #332

Closed
lijiajunply opened this issue Dec 30, 2022 · 8 comments
Closed

Parser<TIn,TOut>.Parse(code) Stack overflow #332

lijiajunply opened this issue Dec 30, 2022 · 8 comments

Comments

@lijiajunply
Copy link

this is my code :
ParserBuilder<OldTokenGeneric, OldLangTree> Parser = new ParserBuilder<OldTokenGeneric, OldLangTree>();
OldParser oldParser = new OldParser();
var buildResult = Parser.BuildParser(oldParser,ParserType.EBNF_LL_RECURSIVE_DESCENT).Result;
var r = buildResult.Parse(code);
var RUN = r.Result;

error:
Stack overflow.
Repeat 1324 times:

at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseInfixExpressionRule(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.NonTerminalClause1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseInfixExpressionRule(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.NonTerminalClause1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseInfixExpressionRule(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.NonTerminalClause1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseInfixExpressionRule(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.NonTerminalClause`1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32)

at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseInfixExpressionRule(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.NonTerminalClause1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseInfixExpressionRule(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.NonTerminalClause1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseInfixExpressionRule(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.NonTerminalClause1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseInfixExpressionRule(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32)
at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String)
at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseNonTerminal(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String, Int32) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseZeroOrMore(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.ZeroOrMoreClause1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32) at sly.parser.llparser.EBNFRecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, sly.parser.syntax.grammar.Rule1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>, Int32, System.String) at sly.parser.llparser.RecursiveDescentSyntaxParser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.String)
at sly.parser.Parser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ParseWithContext(System.Collections.Generic.IList1<sly.lexer.Token1<Old8Lang.CslyMake.OldLandParser.OldTokenGeneric>>, System.Object, System.String) at sly.parser.Parser2[[Old8Lang.CslyMake.OldLandParser.OldTokenGeneric, Old8Lang, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Parse(System.String, System.String)
at Old8Lang.CslyMake.OldLandParser.OldLangInterpreter..ctor(System.String)
at Old8Lang.APIs.CslyUsing(System.String)
at Program.

$(System.String[])

Process finished with exit code 134.

@b3b00
Copy link
Owner

b3b00 commented Dec 30, 2022

Hello @lijiajunply I can not help without any context! please provide your token enum and parser class so I could try to reproduce.
A stackoverflow maybe a symptom of a left recursive grammar. CSLY provides a left recursion mechanism but it may lack some edge case.

@lijiajunply
Copy link
Author

ok.thank you
token:
[Lexer(IndentationAWare = true)]
public enum OldTokenGeneric
{
#region keywords 0 -> 19

    [Lexeme(GenericToken.KeyWord, "IF")] [Lexeme(GenericToken.KeyWord, "if")]
    IF = 1,

    [Lexeme(GenericToken.KeyWord, "ELIF")] [Lexeme(GenericToken.KeyWord, "elif")]
    ELIF = 2,

    [Lexeme(GenericToken.KeyWord, "ELSE")] [Lexeme(GenericToken.KeyWord, "else")]
    ELSE = 3,

    [Lexeme(GenericToken.KeyWord, "WHILE")] [Lexeme(GenericToken.KeyWord, "while")]
    WHILE = 4,

    [Lexeme(GenericToken.KeyWord, "FOR")] [Lexeme(GenericToken.KeyWord, "for")]
    FOR = 5,
    
    [Lexeme(GenericToken.KeyWord, "TRUE")] [Lexeme(GenericToken.KeyWord, "true")]
    TRUE = 6,

    [Lexeme(GenericToken.KeyWord, "FALSE")] [Lexeme(GenericToken.KeyWord, "false")]
    FALSE = 7,

    [Lexeme(GenericToken.KeyWord, "NOT")] [Lexeme(GenericToken.KeyWord, "not")]
    NOT = 8,

    [Lexeme(GenericToken.KeyWord, "AND")] [Lexeme(GenericToken.KeyWord, "and")]
    AND = 9,
    
    [Lexeme(GenericToken.KeyWord, "OR")] [Lexeme(GenericToken.KeyWord, "or")]
    OR = 10,
    
    [Lexeme(GenericToken.KeyWord,"XOR")][Lexeme(GenericToken.KeyWord,"xor")]
    XOR = 11,
    
    [Lexeme(GenericToken.KeyWord,"//")]
    ANNOTATION = 12,
    //[Lexeme(GenericToken.KeyWord, "CLASS")] [Lexeme(GenericToken.KeyWord, "print")]
    //PRINT = 12,
    
    [Lexeme(GenericToken.KeyWord,"\n")]
    HUANHANG = 13,
    
    [Lexeme(GenericToken.KeyWord,"CLASS")][Lexeme(GenericToken.KeyWord,"class")]
    CLASS = 14,
    
    [Lexeme(GenericToken.KeyWord,"FUNC")][Lexeme(GenericToken.KeyWord,"func")]
    FUNC = 15,

    #endregion

    #region literals 20 -> 29
    [Lexeme(GenericToken.Identifier)] IDENTFIER = 20,
    [Lexeme(GenericToken.String)] STRING = 21,
    [Lexeme(GenericToken.Int)] INT = 22,
    [Lexeme(GenericToken.Double)] DOUBLE = 23,
    [Lexeme(GenericToken.Char)] CHAR = 24,
    #endregion

    #region operators 30 -> 49
    
    [Sugar("<-")] SET = 40,

    [Sugar("->")] DIS_SET = 41,
    
    [Sugar( ">")] GREATER = 30,

    [Sugar( "<")] LESSER = 31,

    [Sugar( "==")] EQUALS = 32,

    [Sugar( "!=")] DIFFERENT = 33,

    [Sugar( ".")] CONCAT = 34,

    [Sugar( "-*")] DIRECT = 35,
    
    [Sugar("*-")] DIS_DIRECT = 43,

    [Sugar( "+")] PLUS = 36,

    [Sugar( "-")] MINUS = 37,
    
    [Sugar( "*")] TIMES = 38,

    [Sugar( "/")] DIVIDE = 39,

    #endregion

    #region sugar 50 ->

    [Sugar( "(")] LPAREN = 50,

    [Sugar( ")")] RPAREN = 51,

    EOF = 0

    #endregion

}

parser:

[ParserRoot("root")]
public class OldParser
{
#region root and statement

[Production("root: statement*")]
public OldLangTree Root(List<OldLangTree> statement) => new OldBlock(statement);

[Production("statement: LPAREN statement RPAREN")]
public OldLangTree BOLCK1(Token<OldTokenGeneric> l, OldLangTree statement, Token<OldTokenGeneric> r) =>
    statement as OldStatement;

#endregion

#region expr

[Operation((int) OldTokenGeneric.LESSER, Affix.InFix, Associativity.Right, 50)]
[Operation((int) OldTokenGeneric.GREATER, Affix.InFix, Associativity.Right, 50)]
[Operation((int) OldTokenGeneric.EQUALS, Affix.InFix, Associativity.Right, 50)]
[Operation((int) OldTokenGeneric.DIFFERENT, Affix.InFix, Associativity.Right, 50)]
public OldLangTree binaryComparisonExpression(OldLangTree left, Token<OldTokenGeneric> operatorToken,
    OldLangTree right) => new BinaryOperation(left as OldExpr, operatorToken.TokenID, right as OldExpr);

[Operation((int)OldTokenGeneric.CONCAT, Affix.InFix, Associativity.Right, 100)]
public OldLangTree DotExpr(OldLangTree left, Token<OldTokenGeneric> oper, OldLangTree right) =>
    new BinaryOperation(left as OldExpr, oper.TokenID, right as OldExpr);

[Operation((int)OldTokenGeneric.PLUS, Affix.InFix, Associativity.Right, 20)]
[Operation((int)OldTokenGeneric.MINUS, Affix.InFix, Associativity.Right, 20)]
public OldLangTree BE1(OldLangTree left, Token<OldTokenGeneric> oper, OldLangTree right) =>
    new BinaryOperation(left as OldExpr, oper.TokenID, right as OldExpr);

[Operation((int)OldTokenGeneric.TIMES, Affix.InFix, Associativity.Right, 70)]
[Operation((int)OldTokenGeneric.DIVIDE, Affix.InFix, Associativity.Right, 70)]
public OldLangTree BE2(OldLangTree left, Token<OldTokenGeneric> oper, OldLangTree right) =>
    new BinaryOperation(left as OldExpr, oper.TokenID, right as OldExpr);

[Operation((int)OldTokenGeneric.AND, Affix.InFix, Associativity.Right, 50)]
[Operation((int)OldTokenGeneric.OR, Affix.InFix, Associativity.Right, 50)]
[Operation((int)OldTokenGeneric.XOR, Affix.InFix, Associativity.Right, 50)]
public OldLangTree Bool1(OldExpr left, Token<OldTokenGeneric> oper, OldExpr right) =>
    new BinaryOperation(left, oper.TokenID, right);

[Operation((int)OldTokenGeneric.NOT, Affix.PreFix, Associativity.Right, 100)]
public OldLangTree Bool2(Token<OldTokenGeneric> oper, OldExpr expr) =>
    new BinaryOperation(null, oper.TokenID, expr);

[Operation((int)OldTokenGeneric.MINUS, Affix.PreFix, Associativity.Right, 100)]
public OldLangTree MINUS(Token<OldTokenGeneric> oper, OldExpr expr) =>
    new BinaryOperation(null, oper.TokenID, expr);


#endregion

#region primany

[Operand]
[Production("operand: primary")]
public OldLangTree Operand(OldLangTree prim) => prim;

[Production("primary: LPAREN primary RPAREN")]
public OldLangTree LR(Token<OldTokenGeneric> l, OldLangTree prim, Token<OldTokenGeneric> r) =>
    prim as OldExpr;

[Production("primary: STRING")]
public OldLangTree STRING(Token<OldTokenGeneric> token) => new OldString(token.Value);

[Production("primary: INT")]
public OldLangTree INT(Token<OldTokenGeneric> token) => new OldInt(token.IntValue);

[Production("primary: CHAR")]
public OldLangTree CHAR(Token<OldTokenGeneric> token) => new OldChar(token.Value[0]);

[Production("primary: DOUBLE")]
public OldLangTree DOUBLE(Token<OldTokenGeneric> token) => new OldDouble(double.Parse(token.Value));

[Production("primary: OldParser_expressions")]
public OldLangTree Bool(OldLangTree expr)
{
    var ex = expr as BinaryOperation;
    return new OldBool(ex);
}

[Production("primary: IDENTFIER")]
public OldLangTree IDENTIFIER(Token<OldTokenGeneric> id) => new OldID(id.Value);

[Production("primary: TRUE")]
public OldLangTree BoolTrue(Token<OldTokenGeneric> token) => new OldBool(true);

[Production("primary: FALSE")]
public OldLangTree BoolFalse(Token<OldTokenGeneric> token) => new OldBool(false);

#endregion

#region yuju

[Production("set: IDENTFIER SET[d] OldParser_expressions")]
public OldLangTree Set( Token<OldTokenGeneric> id, OldExpr value) => new OldSet(new OldID(id.Value), value);

[Production("statement: set")]
public OldLangTree SET(OldSet a) => a;

[Production("statement : IF[d] ifblock (ELIF ifblock)* (ELSE  block)?")]
public OldLangTree IF( OldIf ifBlock, List<Group<OldTokenGeneric,OldLangTree>> elif,ValueOption<Group<OldTokenGeneric,OldLangTree>> Else)
{
    var eGrp = Else.Match(x => x, () => null);
    var elseBlock = eGrp?.Value(0) as OldBlock;
    var a = elif.Select(x => x.Value(0) as OldIf).ToList();
    return new OldIf_Elif_Else(ifBlock, a, elseBlock);
}

[Production("ifblock: OldParser_expressions block")]
public OldLangTree IFBLOCK(BinaryOperation binaryOperation, OldBlock block) => new OldIf(binaryOperation, block);

[Production("block: INDENT[d] statement* UINDENT[d]")]
public OldLangTree Block(List<OldLangTree> statements) => new OldBlock(statements);

[Production("statement: FOR set OldParser_expressions  statement  block")]
public OldLangTree FOR(Token<OldTokenGeneric> a, OldSet set, BinaryOperation expr, OldStatement statement, OldBlock block) =>
    new OldFor(set, expr, statement, block);

[Production("statement: WHILE OldParser_expressions block")]
public OldLangTree WHILE(Token<OldTokenGeneric> a, BinaryOperation expr, OldBlock block) => new OldWhile(expr, block);

[Production("statement: IDENTFIER DIRECT[d] IDENTFIER")]
public OldLangTree DIRECT(Token<OldTokenGeneric> id1, Token<OldTokenGeneric> id2) => new OldDirect(new OldID(id1.Value), new OldID(id2.Value));

[Production("statement: FUNC[d] IDENTFIER LPAREN[d] RPAREN[d] block")]
public OldLangTree STAT_FUNC( Token<OldTokenGeneric> id, OldBlock block) => new OldFunc(new OldID(id.Value),block);

[Production("statement: CLASS[d] IDENTFIER set*")]
public OldLangTree CLASS( Token<OldTokenGeneric> id, List<OldLangTree> sets)
{
    Dictionary<OldID, OldExpr> c = new Dictionary<OldID, OldExpr>();
    foreach (var VARIABLE in sets)
    {
        var a = VARIABLE as OldSet;
        c.Add(a.Id,a.Value);
    }
    return new OldAny(new OldID(id.Value), c);
}

[Production("statement: IDENTFIER SET[d] IDENTFIER LPAREN RPAREN")]
public OldLangTree INSTANTIATE(Token<OldTokenGeneric> id, Token<OldTokenGeneric> a, Token<OldTokenGeneric> otherid, Token<OldTokenGeneric> b,
    Token<OldTokenGeneric> c) => new OldSet(new OldID(id.Value), new OldID(otherid.Value));

#endregion

}

@b3b00
Copy link
Owner

b3b00 commented Dec 30, 2022

Thanks , I still miss a sample of the code you're trying to parse.

@lijiajunply
Copy link
Author

test:
a <- 1

the code equivalent "a = 1" as python

@b3b00
Copy link
Owner

b3b00 commented Dec 30, 2022

Ok I've found it.

Simply removing rule :

[Production("primary: OldParser_expressions")]
public OldLangTree Bool(OldLangTree expr)
{
    var ex = expr as BinaryOperation;
    return new OldBool(ex);
}

This is indeed a case of left recursion that i did not catch. I will look at it.
With this rule your stating
a primary can be an OldParser_expressions
but as primary is tagged as [Operand] an OldParser_expressions ca also be a primary so looping endlessly.

Don't forget to close issue if ok with that

b3b00 added a commit that referenced this issue Dec 30, 2022
@lijiajunply
Copy link
Author

thank you very much

b3b00 added a commit that referenced this issue Dec 30, 2022
@lijiajunply
Copy link
Author

ok

@b3b00
Copy link
Owner

b3b00 commented Dec 30, 2022

I've pushed a fix. a build is running and soon version 2.9.3.1 will add an error message when your left recursion case arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants