Description
An escaped character literal ('\n', '\t', '\\', '\'', '\0', …) fails to parse. The lexer rule that matches escaped char literals returns the token YAP — which is the yap/char type keyword token — instead of a CHAR literal token, so the parser sees a type keyword where an expression is required and aborts.
Plain single-character literals ('a') work, because they are matched by a different rule that correctly returns CHAR.
Minimal reproduction code
skibidi main {
yap c = '\n';
yapping("%d", c);
bussin 0;
}
Expected behavior
Prints 10 (the code point of newline) and exits 0 — just as yap c = 'a'; correctly prints 97.
Actual behavior
$ ./brainrot escape.brainrot
Error: syntax error, unexpected YAP at line 1
Parsing failed
Exit code 1. Every escape sequence in a char literal is affected.
Brainrot version / commit
19b9563
Operating system
Ubuntu on WSL2 (Linux 5.15)
Additional context
Root cause: lang.l. The escaped-char-literal rule \'([^\\\']|\\.)\' decodes the escape correctly into yylval.ival but ends with return YAP;. YAP is the type keyword token ("yap" { current_var_type = VAR_CHAR; return YAP; }). The plain-char rule '.' correctly does return CHAR;. The escaped-char rule should also return CHAR;.
Description
An escaped character literal (
'\n','\t','\\','\'','\0', …) fails to parse. The lexer rule that matches escaped char literals returns the tokenYAP— which is theyap/chartype keyword token — instead of aCHARliteral token, so the parser sees a type keyword where an expression is required and aborts.Plain single-character literals (
'a') work, because they are matched by a different rule that correctly returnsCHAR.Minimal reproduction code
Expected behavior
Prints
10(the code point of newline) and exits 0 — just asyap c = 'a';correctly prints97.Actual behavior
Exit code 1. Every escape sequence in a char literal is affected.
Brainrot version / commit
19b9563
Operating system
Ubuntu on WSL2 (Linux 5.15)
Additional context
Root cause:
lang.l. The escaped-char-literal rule\'([^\\\']|\\.)\'decodes the escape correctly intoyylval.ivalbut ends withreturn YAP;.YAPis the type keyword token ("yap" { current_var_type = VAR_CHAR; return YAP; }). The plain-char rule'.'correctly doesreturn CHAR;. The escaped-char rule should alsoreturn CHAR;.