Flex logic / C ++ regex error
I have done my best to include all (and only) the information you need. Let me know if seeing more can help you help me.
I am having problems with my regex. My program prints in lexeme-token pairs of a .txt file. Everything works fine except for IDs and integers. For example, the token for the ID is 262.
Sample input file:
function main a: integer returns integer;
b: integer is a * 2;
Output example:
function - 269
maina - 262
integer - 272
returns - 274
integer - 272
; - 59
b - 262
integer - 272
is - 271
a - 262
2 - 263
; - 59
Correct conclusion:
function - 269
main - 262
a - 262
: - 58
integer - 272
returns - 274
integer - 272
; - 59
b - 262
: - 58
integer - 272
is - 271
a - 262
* - 261
2 - 263
; - 59
To summarize, it concatenates the two space-separated IDs and also removes any token after the ID.
+3
source to share
1 answer