I am currently stuck with a rule I am trying to parse using boost spirit x3. Here is the EBNF(using the % operator from spirit for lists) for what I am trying to parse:
I solved this problem and the solution was incredibly easy. The trick is to change the grammar, so I dont have a left recursion, and it parses nice into my structs.
so I changed
type ::= class_type | lambda_type
lambda_type ::= more_arg_lambda | one_arg_lambda
more_arg_lambda ::= "(", type%",", ")", "=>", type
one_arg_lambda ::= type, "=>", type <- here is the left recursion
class_type ::= identifier%"::", ["<", type%",", ">"]
to
type ::= class_type | lambda_type
lambda_type ::= more_arg_lambda | one_arg_lambda
more_arg_lambda ::= "(", type%",", ")", "=>", type
one_arg_lambda ::= class_type, "=>", type <- here is the magic trick
class_type ::= identifier%"::", ["<", type%",", ">"]
this second grammar descripes the exaclty same language, but without left recursion, and without changing the structure of the grammar. This was actualy luck and doesnt work for every grammar obviously.