summaryrefslogtreecommitdiff
path: root/expr.l
diff options
context:
space:
mode:
Diffstat (limited to 'expr.l')
-rw-r--r--expr.l74
1 files changed, 0 insertions, 74 deletions
diff --git a/expr.l b/expr.l
deleted file mode 100644
index 57b3de2..0000000
--- a/expr.l
+++ /dev/null
@@ -1,74 +0,0 @@
-%{
-#define _XOPEN_SOURCE 700
-#include <locale.h>
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "expr.h"
-
-#include "y.tab.h"
-
-extern int yyparse(void);
-
-%}
-
-DIGIT [0-9]
-
-%%
-
-"|" return '|';
-"&" return '&';
-"=" return '=';
-">" return '>';
-">=" return GE;
-"<" return '<';
-"<=" return LE;
-"!=" return NE;
-"+" return '+';
-"-" return '-';
-"*" return '*';
-"/" return '/';
-"%" return '%';
-"(" return '(';
-")" return ')';
-":" return ':';
-{DIGIT}+ { yylval.u.i = atoi(yytext); return yylval.type = INTEGER; }
--{DIGIT}+ { yylval.u.i = atoi(yytext); return yylval.type = INTEGER; }
-.+ { yylval.u.s = strdup(yytext); return yylval.type = STRING; }
-\n ;
-
-%%
-
-int main(int argc, char *argv[])
-{
- setlocale(LC_ALL, "");
-
- int c;
- while ((c = getopt(argc, argv, "")) != -1) {
- switch (c) {
- default:
- return -1;
- }
- }
-
- if (optind >= argc) {
- fprintf(stderr, "expr: missing operands\n");
- return 1;
- }
-
- size_t n = 1;
- for (int i = optind; i < argc; i++) {
- n += strlen(argv[i]) + 1;
- }
-
- FILE *mem = fmemopen(NULL, n, "w+");
- for (int i = optind; i < argc; i++) {
- fprintf(mem, "%s\n", argv[i]);
- }
- rewind(mem);
-
- yyin = mem;
-
- return yyparse();
-}