add initial empty C, flex, and bison sources

This commit is contained in:
josh committed 2018-04-06 11:38:27 -04:00
1 parent 8d8c08cd85
commit 3ead22e0cf
5 files changed
+84 -2

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
#include <stdio.h>
int main(int argc, char * argv[])
{
printf("coming soon...\n");
return 0;
}
+4
View File
@@ -0,0 +1,4 @@
#ifndef PARSER_H
#define PARSER_H
#endif
+15
View File
@@ -0,0 +1,15 @@
%option nounput
%option bison-locations
%{
#include "parser.h"
#include "parser.tab.h"
%}
%x str
%%
%%
+38
View File
@@ -0,0 +1,38 @@
%{
#include <stdio.h>
#include "parser.h"
#include "parser.tab.h"
#define yyerror(msg) handle_error(msg, &yyloc)
int yylex(YYSTYPE *, YYLTYPE *);
static void handle_error(const char * str, const YYLTYPE * yylloc);
%}
%pure-parser
%locations
%error-verbose
%token PLUS;
%token MINUS;
%%
translation_unit: PLUS;
%%
static void handle_error(const char * str, const YYLTYPE * yylloc)
{
fprintf(stderr, "error: %s (line %d, column %d)\n",
str,
yylloc->first_line,
yylloc->first_column);
}
int yywrap(void)
{
return 1;
}