DragonCompiler icon indicating copy to clipboard operation
DragonCompiler copied to clipboard

A bug in lexer.c

Open HelloSakura opened this issue 2 years ago • 0 comments

When I am learning this lecture, I found a bug in lexer.c. This lexer can't distinguish between eg. 0xaa, xaa. The former should be recognized as a hexadecimal token and it works fine. According to C standard,the latter should be recognized as a identifier token, but the lexer treats it as a hexadecimal number in fact. When lexer gets “0xab”, then do pop token 0 skip ‘x' convert "ab" to int

When lexer gets "xab", the program will directly goto case 'x' and treat it as a hexadecimal number. Obviously it's not.

HelloSakura avatar Apr 15 '23 09:04 HelloSakura