5

Got this simple grammar:

grammar H1 {
    token TOP { <h1> }
    token h1 { \#  }
}

Results in: Null regex not allowed Missing block

Google turns up next to nothing on it.

StevieD
  • 6,925
  • 2
  • 25
  • 45
  • 3
    With `#`, you start a [comment](https://docs.raku.org/language/regexes#Regex_readability:_whitespace_and_comments) in the token; then your token is effectively ``\`` but you don't escape anything with it, hence the error(s). – Mustafa Aydın Feb 01 '22 at 07:18
  • See also [`regex { \# }` doesn't parse](https://github.com/rakudo/rakudo/issues/4387). – raiph Feb 01 '22 at 18:56
  • "Null regex not allowed Missing block" That's two error messages without a newline between them. In other words, the parser is well and truly confused! – raiph Feb 01 '22 at 19:01

1 Answers1

4

Still not sure why escaping doesn't work, but this does:

grammar H1 {
    token TOP { <h1> }
    token h1 { '#'  }
}
StevieD
  • 6,925
  • 2
  • 25
  • 45