goccmack / gocc

Parser / Scanner Generator
Other
604 stars 48 forks source link

empty production alternative: Maybe you are missing the "empty" keyword in Letter #138

Open arater opened 9 months ago

arater commented 9 months ago

` / Misc ------------------------------------------------------------------/

Integer ::= Digit | Integer Digit ; Digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | empty ;

Letters ::= Letter Letters | empty; Letter ::= 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | empty ;

Char ::= PrintableChar | WhitespaceChar ; PrintableChar ::= 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | OtherSymbols ;

WhitespaceChar ::= Space | Tab | NewLine ; OtherSymbols ::= '!' | '@' | '#' | '$' | '%' | '^' | '&' | '*' | '(' | ')' | '-' | '+' | '=' | '{' | '}' | '[' | ']' | '|' | '\' | ':' | ';' | '"' | '\'' | '<' | '>' | ',' | '.' | '/' | '?' ; Space ::= ' ' ; Tab ::= #x9 ; NewLine ::= CarriageReturn | LineFeed ;

CarriageReturn ::= '\r' ; LineFeed ::= '\n' ; `

I am trying to create bnf file for regular expressions grammars but i am getting always this error and i do not understand why it is happening? Can you help me or do you have any regular expressions bnf file that work witc gocc, can you provide me?

awalterschulze commented 9 months ago

You can try single quotes for Digit as in '0' - '9' And gocc syntax is different it isn't :==, but only :

You could also try 'A' - 'Z' so you don't have to list all alternatives

But I am just providing some random suggestions, think it will help to go in the right direction, but not necessarily fix all issues