From 63747d6ec38205c517af303737868a0b6e18f3a0 Mon Sep 17 00:00:00 2001 From: angel Date: Mon, 25 Apr 2005 16:19:08 +0000 Subject: [PATCH] Syntax errors (lex/yacc generated) and semantic errors has been unified, so both generate a compilation error an a non-zero return from compile(). git-svn-id: file:///home/angel/tmp/svn-triptico/ahxm/trunk@493 c87de0a0-a11c-0410-a1e5-866214bc28b2 --- compiler.y | 17 +++++++++++------ wav.c | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/compiler.y b/compiler.y index 97b0d9d..f8f5821 100644 --- a/compiler.y +++ b/compiler.y @@ -116,6 +116,10 @@ static int _arp_transpose; static float _arp_volume; static int _arp_track; +int compiler_error=0; + +extern int yyline; + /******************* Code ********************/ @@ -123,11 +127,13 @@ static int _arp_track; void _c_err(char * e1, char * e2, char * e3) /* reports an error from the compiler */ { - printf("Compiler error:"); + printf("ahxm:"); if(e1 != NULL) printf(" %s", e1); if(e2 != NULL) printf(" %s", e2); if(e3 != NULL) printf(" %s", e3); - printf("\n"); + printf(" in line %d\n", yyline); + + compiler_error++; } @@ -812,11 +818,9 @@ xc_cmd: %% -extern int yyline; - void yyerror(char * s) { - printf("%s in line %d\n", s, yyline); + _c_err(s, NULL, NULL); } #ifdef QQ @@ -846,6 +850,7 @@ int compile(char * code) { _track=0; yyline=1; + compiler_error=0; /* default settings */ _add_tempo_event(-2, 120.0); @@ -854,5 +859,5 @@ int compile(char * code) push_code(code, 1, 0); - return(yyparse()); + return(yyparse() + compiler_error); } diff --git a/wav.c b/wav.c index ebf8769..2df0800 100644 --- a/wav.c +++ b/wav.c @@ -255,7 +255,7 @@ int main(void) #endif /* compile("T81.67 o5c1*10 \\ z1s0.5 t-1 x4~0.6,2~0.3,2.~0.2 | s0.8z8 c'gb&c'b&gfg| \\ t-1 o6s1 c1*3.5 b,2 c1*4 "); */ - if(compile(" { pat 'samples/acpiano.pat' echo 0 1s 0.5\n/* broken\ncomment */ echo 1 1.5s 0.3 }\n z1 v1 |||\n\\\n{ wav 'samples/amen1.wav' c5 c0 g10\nflanger 0 1s 0.9 3ms 0.1 0.5 flanger 1 1s 0.9 3ms 0.1 0 }\no5 c1*4")) + if(compile("{ pat 'samples/acpiano.pat' echo 0 1s 0.5\n/* broken\ncomment */ echo 1 1.5s 0.3 }\n z1 v1 |||\n\\\n{ wav 'samples/amen1.wav' c5 c0 g10\nflanger 0 1s 0.9 3ms 0.1 0.5 flanger 1 1s 0.9 3ms 0.1 0 }\no5 c1*4")) { exit(0); } -- 2.11.4.GIT