42School / norminette

Official 42 norminette
MIT License
956 stars 140 forks source link

Norminette parses strings as long-strings #420

Closed NiumXp closed 6 months ago

NiumXp commented 1 year ago

Describe the bug String parsing behavior in norminette is like "[^"]+", so it doesn't raise an error when a string is not closed.

Erroneous code

void    main(void)
{
    char *str = "Será que
    se botar errado
    assim, a norminette pega?";
}
test.c - IsFuncDeclaration In "GlobalScope" from "None" line 1":
                <VOID> <TAB> <IDENTIFIER=main> <LPARENTHESIS> <VOID> <RPARENTHESIS> <NEWLINE>
test.c - IsBlockStart In "Function" from "GlobalScope" line 2":
                <LBRACE> <NEWLINE>
test.c - IsVarDeclaration In "Function" from "GlobalScope" line 3":
                <TAB> <CHAR> <SPACE> <MULT> <IDENTIFIER=str> <SPACE> <ASSIGN> <SPACE> <STRING="Será que
        se botar errado
        assim, a norminette pega?"> <SEMI_COLON> <NEWLINE>
test.c - IsBlockEnd In "Function" from "GlobalScope" line 4":
                <RBRACE> <NEWLINE>
test.c: Error!
Error: INVALID_HEADER       (line:   1, col:   1):      Missing or invalid 42 header
Error: SPACE_REPLACE_TAB    (line:   3, col:   9):      Found space when expecting tab
Error: DECL_ASSIGN_LINE     (line:   3, col:  15):      Declaration and assignation on a single line

Additional infos ...

Additional context ...

matthieu42Network commented 1 year ago

Hello, it's expected that the norminette has undefined behavior for code that don't compile (we use Clang as reference). So this kind of fix is not really needed but we welcome it nonetheless :)