4 #include "glps_parser.h"
6 #define YYSTYPE GLPS_STYPE
13 int main(
int argc,
char *argv[])
17 in = fopen(argv[1],
"r");
19 fprintf(stderr,
"Failed to open %s\n", argv[1]);
28 glps_lex_init_extra(&ctxt, &scanner);
30 glps__switch_to_buffer(glps__create_buffer(in, 1024, scanner), scanner);
36 int tok = glps_lex(&lval, scanner);
42 printf(
"Number: %g\n", lval.real);
45 printf(
"String: \"%s\"\n", lval.string->str.c_str());
49 printf(
"KW: %s\n", lval.string->str.c_str());
70 printf(
"Literal: '%c'\n", tok);
74 printf(
"Unknown token type '%c' (%d)\n", tok, tok);
82 glps_lex_destroy(scanner);
84 if(ctxt.last_error.size()) {
86 fprintf(stderr,
"Error: %s\n", ctxt.last_error.c_str());