%{
#include <stdio.h>
#include "y
.tab
.h"
// Include the header generated by YACC
#include <stdlib.h> // For atof
%}
%%
// Match numbers and return DIGIT token
[0-9]+ {
yylval.dval = atof(yytext); // Convert string to double
return DIGIT; // Return DIGIT token
}
// Match newline character
\n {
return '\n'; // Return newline character
}
// Match any other character and return it
. {
return yytext[0]; // Return the character itself
}
%%
// Main function to
call the parser
int main() {
return yyparse(); // Start parsing
}
// Error handling function
void yyerror(char *s) {
fprintf(stderr, "Error: %s\n", s); // Print error message
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlICJ5LnRhYi5oIiAvLyBJbmNsdWRlIHRoZSBoZWFkZXIgZ2VuZXJhdGVkIGJ5IFlBQ0MKI2luY2x1ZGUgPHN0ZGxpYi5oPiAvLyBGb3IgYXRvZgolfQoKJSUKCi8vIE1hdGNoIG51bWJlcnMgYW5kIHJldHVybiBESUdJVCB0b2tlbgpbMC05XSsgewogICAgeXlsdmFsLmR2YWwgPSBhdG9mKHl5dGV4dCk7IC8vIENvbnZlcnQgc3RyaW5nIHRvIGRvdWJsZQogICAgcmV0dXJuIERJR0lUOyAvLyBSZXR1cm4gRElHSVQgdG9rZW4KfQoKLy8gTWF0Y2ggbmV3bGluZSBjaGFyYWN0ZXIKXG4gewogICAgcmV0dXJuICdcbic7IC8vIFJldHVybiBuZXdsaW5lIGNoYXJhY3Rlcgp9CgovLyBNYXRjaCBhbnkgb3RoZXIgY2hhcmFjdGVyIGFuZCByZXR1cm4gaXQKLiB7CiAgICByZXR1cm4geXl0ZXh0WzBdOyAvLyBSZXR1cm4gdGhlIGNoYXJhY3RlciBpdHNlbGYKfQoKJSUKCi8vIE1haW4gZnVuY3Rpb24gdG8gY2FsbCB0aGUgcGFyc2VyCmludCBtYWluKCkgewogICAgcmV0dXJuIHl5cGFyc2UoKTsgLy8gU3RhcnQgcGFyc2luZwp9CgovLyBFcnJvciBoYW5kbGluZyBmdW5jdGlvbgp2b2lkIHl5ZXJyb3IoY2hhciAqcykgewogICAgZnByaW50ZihzdGRlcnIsICJFcnJvcjogJXNcbiIsIHMpOyAvLyBQcmludCBlcnJvciBtZXNzYWdlCn0=