'Null regex not allowed Missing block

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.



Solution 1:[1]

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

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 StevieD