llvm/jlc/jlc.y
josh e249ae799d moved jl.* to jlc.*, updated makefile
git-svn-id: svn://anubis/misc/llvm@68 bd8a9e45-a331-0410-811e-c64571078777
2008-11-04 18:34:32 +00:00

74 lines
918 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 MOD;
%token SEMICOLON;
%token COLON;
%token DOT;
%token DQUOTE;
%token SQUOTE;
%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"); }
| assignment program { printf("Saw an assignment\n"); }
number: BIN_NUMBER
| OCT_NUMBER
| DEC_NUMBER
| HEX_NUMBER
;
assignment: ID ASSIGN number
;