llvm/jlc/jl.y
josh 0f8b3ff1a8 added lots of tokens
git-svn-id: svn://anubis/misc/llvm@66 bd8a9e45-a331-0410-811e-c64571078777
2008-11-04 17:27:59 +00:00

66 lines
776 B
Plaintext

%{
#include <stdio.h>
extern FILE * yyin;
void yyerror(const char * str)
{
fprintf(stderr, "error: %s\n", str);
}
int yywrap()
{
return 1;
}
int main(int argc, char * argv[])
{
if (argc > 0)
{
yyin = fopen(argv[1], "r");
}
yyparse();
}
%}
%token ASSIGN;
%token EQUAL;
%token LEQ;
%token GEQ;
%token LSHIFT;
%token RSHIFT;
%token INCREMENT;
%token DECREMENT;
%token PLUS;
%token MINUS;
%token TIMES;
%token DIVIDE;
%token BIN_NUMBER;
%token HEX_NUMBER;
%token OCT_NUMBER;
%token DEC_NUMBER;
%token RETURN;
%token ID;
%%
program: /* empty */
| number program { printf("Saw a number\n"); }
number: BIN_NUMBER
| OCT_NUMBER
| DEC_NUMBER
| HEX_NUMBER
{
printf("Saw a number\n");
}
;