llvm/jlc/jlc.y
josh b1d084a242 added bracket/brace tokens
git-svn-id: svn://anubis/misc/llvm@71 bd8a9e45-a331-0410-811e-c64571078777
2008-11-04 22:44:36 +00:00

94 lines
1.2 KiB
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 AND;
%token OR;
%token NOT;
%token BIT_AND;
%token BIT_OR;
%token BIT_XOR;
%token BIT_NEG;
%token INCREMENT;
%token DECREMENT;
%token PLUS;
%token MINUS;
%token TIMES;
%token DIVIDE;
%token MOD;
%token SEMICOLON;
%token COLON;
%token QUESTION;
%token DOLLAR;
%token DOT;
%token DQUOTE;
%token SQUOTE;
%token LCURLY;
%token RCURLY;
%token LBRACKET;
%token RBRACKET;
%token LPAREN;
%token RPAREN;
%token BIN_NUMBER;
%token HEX_NUMBER;
%token OCT_NUMBER;
%token DEC_NUMBER;
%token ALIAS;
%token MODULE;
%token RETURN;
%token USE;
%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
;