%{
// Declarations section
: You can declare variables
, include header files
, etc
. #include <stdio.h>
%}
%%
// Rules section: Specify your patterns and corresponding actions.
[0-9]+ { printf
("
Number: %s\n", yytext); } [a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier: %s\n", yytext); }
\n { /* ignore newlines */ }
[ \t]+ { /* ignore whitespace */ }
. { printf("Unknown character: %s\n", yytext); }
%%
// Code section: The main function and other C code go here.
int main(void) {
yylex(); // Calls the lexical analyzer
return 0;
}
int yywrap() {
return 1;
}
JXsgCi8vIERlY2xhcmF0aW9ucyBzZWN0aW9uOiBZb3UgY2FuIGRlY2xhcmUgdmFyaWFibGVzLCBpbmNsdWRlIGhlYWRlciBmaWxlcywgZXRjLgojaW5jbHVkZSA8c3RkaW8uaD4KJX0KCiUlIAovLyBSdWxlcyBzZWN0aW9uOiBTcGVjaWZ5IHlvdXIgcGF0dGVybnMgYW5kIGNvcnJlc3BvbmRpbmcgYWN0aW9ucy4KClswLTldKyAgICAgICAgICAgICAgeyBwcmludGYoIk51bWJlcjogJXNcbiIsIHl5dGV4dCk7IH0gClthLXpBLVpfXVthLXpBLVowLTlfXSogICB7IHByaW50ZigiSWRlbnRpZmllcjogJXNcbiIsIHl5dGV4dCk7IH0KXG4gICAgICAgICAgICAgICAgICB7IC8qIGlnbm9yZSBuZXdsaW5lcyAqLyB9ClsgXHRdKyAgICAgICAgICAgICAgeyAvKiBpZ25vcmUgd2hpdGVzcGFjZSAqLyB9Ci4gICAgICAgICAgICAgICAgICAgeyBwcmludGYoIlVua25vd24gY2hhcmFjdGVyOiAlc1xuIiwgeXl0ZXh0KTsgfQoKJSUgCi8vIENvZGUgc2VjdGlvbjogVGhlIG1haW4gZnVuY3Rpb24gYW5kIG90aGVyIEMgY29kZSBnbyBoZXJlLgoKaW50IG1haW4odm9pZCkgewogICAgeXlsZXgoKTsgLy8gQ2FsbHMgdGhlIGxleGljYWwgYW5hbHl6ZXIKICAgIHJldHVybiAwOwp9CgppbnQgeXl3cmFwKCkgewogICAgcmV0dXJuIDE7Cn0K