kach / nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
https://nearley.js.org
MIT License
3.57k stars 231 forks source link

Constantly get "Possible infinite loop detected! Check your grammar for infinite recursion." #603

Closed acanthite1855 closed 2 years ago

acanthite1855 commented 2 years ago

Most likely I did something dumb, but to be honest I don't know what, because I don't really know the grammars theory. Trying nearley in playground, but this one constantly causing error "Possible infinite loop detected! Check your grammar for infinite recursion."

DATA -> FONT_MODIFIER | COLOR_MODIFIER | TEXT

TEXT -> [^\n\^\&]:+

FONT_MODIFIER -> "&" [iIbBsS] {% ([_, value]) => ({ type: "font", value }) %}

COLOR_MODIFIER -> "^" [aAbBcCdDfFgGiIkKmMoOpPrRsSwWyYnN] {% ([_, value]) => ({ type: "color", value }) %}

Am I doing something wrong or it is a bug?