Newer
Older
test_yacc_lex / testl0.l
@ApricotSavor ApricotSavor on 13 Jan 2017 526 bytes adder test
%{
#include <stdio.h>
#include "node.h"
#include "y.tab.h"

int
yywrap(void)
{
  return 1;
}
%}

%%
"+" return ADD;
"-" return SUB;
"*" return MUL;
"/" return DIV;
"\n" return CR;

"if" return IF;
"(" return COND_BEGIN;
")" return COND_END;
"else" return ELSE;
"endif" return ENDIF;

[1-9][0-9]* {
  double temp;
  sscanf(yytext, "%lf", &temp);
  yylval.double_value = temp;
  return DOUBLE_LITERAL;
}
[0-9]*\.[0-9]* {
  double temp;
  sscanf(yytext, "%lf", &temp);
  yylval.double_value = temp;
  return DOUBLE_LITERAL;
}
%%