diff --git a/tools/qfcc/configure.in b/tools/qfcc/configure.in index aafed06f2..7bc247543 100644 --- a/tools/qfcc/configure.in +++ b/tools/qfcc/configure.in @@ -20,6 +20,8 @@ dnl Checks for programs. AC_PROG_INSTALL AC_PROG_CC AC_PROG_CPP +AC_PROG_YACC +AM_PROG_LEX set $CC if test "$1" = gcc; then diff --git a/tools/qfcc/source/.gitignore b/tools/qfcc/source/.gitignore index b203424db..2a4999d19 100644 --- a/tools/qfcc/source/.gitignore +++ b/tools/qfcc/source/.gitignore @@ -2,5 +2,7 @@ Makefile.in Makefile .deps +qc-lex.c +qc-parse.c +qc-parse.h qfcc - diff --git a/tools/qfcc/source/Makefile.am b/tools/qfcc/source/Makefile.am index 58debf697..86d8d8fc8 100644 --- a/tools/qfcc/source/Makefile.am +++ b/tools/qfcc/source/Makefile.am @@ -29,8 +29,9 @@ AUTOMAKE_OPTIONS= foreign INCLUDES= -I$(top_srcdir)/include +YFLAGS = -d bin_PROGRAMS= qfcc -qfcc_SOURCES= cmdlib.c pr_comp.c pr_def.c pr_imm.c pr_lex.c pr_opcode.c qfcc.c +qfcc_SOURCES= cmdlib.c pr_comp.c pr_def.c pr_imm.c pr_lex.c pr_opcode.c qfcc.c qc-parse.y qc-lex.l qfcc_LDADD= -lQFutil diff --git a/tools/qfcc/source/qc-lex.l b/tools/qfcc/source/qc-lex.l new file mode 100644 index 000000000..0bddf4ca6 --- /dev/null +++ b/tools/qfcc/source/qc-lex.l @@ -0,0 +1,41 @@ +%{ +#include "qfcc.h" +#include "qc-parse.h" + +#define YY_NO_UNPUT + +%} + +DIGIT [0-9] +ID [a-zA-Z_][a-zA-Z_0-9]* + +%% + +{DIGIT}+"."{DIGIT}* + +{ID} + +"!"|"("|")"|"{"|"}"|"."|"*"|"/"|"&"|"|"|"+"|"-"|"="|"["|"]" return yytext[0]; + +"&&" return AND; +"||" return OR; +"==" return EQ; +"!=" return NE; +"<=" return LE; +">=" return GE; +"<" return LT; +">" return GT; + +^# + +\n + +. + +%% + +int +yywrap (void) +{ + return 1; +}