summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2012-06-28 22:16:59 -0400
committerOri Bernstein <ori@eigenstate.org>2012-06-28 22:16:59 -0400
commit63422f515cbcad49052eef628f2a3a16e368c60e (patch)
treea8bd54042411579765282ad66dad1522241f4a9a
parent7df2af4eb30522cf68363999d3d035bc46531fee (diff)
downloadmc-63422f515cbcad49052eef628f2a3a16e368c60e.tar.gz
Stub out grammar for matches.
-rw-r--r--8/main.c5
-rw-r--r--mk/lexyacc.mk6
-rw-r--r--parse/gram.y26
-rw-r--r--parse/parse.h1
4 files changed, 32 insertions, 6 deletions
diff --git a/8/main.c b/8/main.c
index bc98218..d6021e5 100644
--- a/8/main.c
+++ b/8/main.c
@@ -65,8 +65,11 @@ int main(int argc, char **argv)
break;
case 'd':
debug = 1;
- while (optarg && *optarg)
+ while (optarg && *optarg) {
+ if (*optarg == 'y')
+ yydebug = 1;
debugopt[*optarg++ & 0x7f] = 1;
+ }
break;
case 'I':
lappend(&incpaths, &nincpaths, optarg);
diff --git a/mk/lexyacc.mk b/mk/lexyacc.mk
index 8d104f6..9d39bb4 100644
--- a/mk/lexyacc.mk
+++ b/mk/lexyacc.mk
@@ -1,9 +1,9 @@
NECFLAGS = $(subst -Werror,,$(subst -Wall,,$(CFLAGS)))
-%.o: %.y .deps
- yacc -d -o$*.c $<
+%.o: %.y
+ yacc -dt -o$*.c $<
$(CC) -c $(NECFLAGS) $*.c
-%.o: %.l .deps
+%.o: %.l
flex -o$*.c $<
$(CC) -c $(NECFLAGS) $*.c
diff --git a/parse/gram.y b/parse/gram.y
index 0328f89..8aef38d 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -127,11 +127,12 @@ Stab *curscope;
%type <node> bandexpr cmpexpr unioncons addexpr mulexpr shiftexpr prefixexpr postfixexpr
%type <node> funclit arraylit name block blockbody stmt label use
%type <node> decl declbody declcore structelt
-%type <node> ifstmt forstmt whilestmt elifs optexprln
+%type <node> ifstmt forstmt whilestmt matchstmt elifs optexprln
+%type <node> pat match
%type <node> castexpr
%type <ucon> unionelt
-%type <nodelist> arglist argdefs structbody params
+%type <nodelist> arglist argdefs structbody params matches
%type <uconlist> unionbody
%union {
@@ -528,6 +529,7 @@ stmt : decl
| ifstmt
| forstmt
| whilestmt
+ | matchstmt
| Tendln {$$ = NULL;}
;
@@ -558,6 +560,26 @@ elifs : Telif exprln blockbody elifs
{$$ = NULL;}
;
+matchstmt: Tmatch exprln matches Tendblk
+ {$$ = NULL;}
+ ;
+
+matches : match
+ {$$.nl = NULL; $$.nn = 0;
+ if ($1)
+ lappend(&$$.nl, &$$.nn, $1);}
+ | matches match
+ {if ($2)
+ lappend(&$$.nl, &$$.nn, $2);}
+ ;
+
+match : pat Tcolon block {$$ = NULL;}
+ | Tendln {$$ = NULL;}
+ ;
+
+pat : literal {$$ = NULL;}
+ ;
+
block : blockbody Tendblk
| Tendblk {$$ = NULL;}
;
diff --git a/parse/parse.h b/parse/parse.h
index 681ecbf..5e94dcc 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -423,6 +423,7 @@ char *swapsuffix(char *buf, size_t sz, char *s, char *suf, char *swap);
/* Options to control the compilation */
extern int debug;
+extern int yydebug;
extern char debugopt[128];
extern int asmonly;
extern char *outfile;