lac : diff b89fc5e8 214ca407

Branch: master

Commit: b89fc5e83f5748ee9f2bcacbd5093746b7cd5fd3

Author: Gianluca Guida <glguida@tlbflush.org>
Date: Tue Mar 7 19:00:06 UTC 2017
Parent: 214ca407357fd1f95de2e668d577d3eee919c6d9
Log message:

    sexpr: exception on syntax error

    1: diff --git a/src/lib/sexpr.c b/src/lib/sexpr.c
    2: index bd24ab5..bdd1e6f 100644
    3: --- a/src/lib/sexpr.c
    4: +++ b/src/lib/sexpr.c
    5: @@ -24,11 +24,11 @@
    6:  */
    7:  #include <stdio.h>
    8:  /************ Begin %include sections from the grammar ************************/
    9: -#line 1 "sexpr.lmn"
   10: +#line 1 "sexpr.y"
   11:   #include <lac.h> 
   12: -#line 2 "sexpr.lmn"
   13: +#line 2 "sexpr.y"
   14:   #include <assert.h> 
   15: -#line 3 "sexpr.lmn"
   16: +#line 3 "sexpr.y"
   17:   #include "private.h" 
   18:  #line 34 "sexpr.c"
   19:  /**************** End of %include directives **********************************/
   20: @@ -814,65 +814,65 @@ static void yy_reduce(
   21:  /********** Begin reduce actions **********************************************/
   22:          YYMINORTYPE yylhsminor;
   23:        case 0: /* sexprlist ::= sexprlist sexpr */
   24: -#line 15 "sexpr.lmn"
   25: +#line 15 "sexpr.y"
   26:  { if (cb != NULL) { cb->res = cb->fn(yymsp[0].minor.yy6, cb->opq); } }
   27:  #line 820 "sexpr.c"
   28:          break;
   29:        case 1: /* sexprlist ::= */
   30: -#line 16 "sexpr.lmn"
   31: +#line 16 "sexpr.y"
   32:  { /* */ }
   33:  #line 825 "sexpr.c"
   34:          break;
   35:        case 2: /* sexpr ::= atom */
   36:        case 9: /* sexpr ::= list */ yytestcase(yyruleno==9);
   37: -#line 18 "sexpr.lmn"
   38: +#line 18 "sexpr.y"
   39:  { yylhsminor.yy6 = yymsp[0].minor.yy0; }
   40:  #line 831 "sexpr.c"
   41:    yymsp[0].minor.yy6 = yylhsminor.yy6;
   42:          break;
   43:        case 3: /* sexpr ::= QUOTE sexpr */
   44: -#line 19 "sexpr.lmn"
   45: +#line 19 "sexpr.y"
   46:  { yymsp[-1].minor.yy6 = cons(sym_quote, cons(yymsp[0].minor.yy6, NIL)); }
   47:  #line 837 "sexpr.c"
   48:          break;
   49:        case 4: /* sexpr ::= QUASI sexpr */
   50: -#line 20 "sexpr.lmn"
   51: +#line 20 "sexpr.y"
   52:  { yymsp[-1].minor.yy6 = cons(sym_quasiquote, cons(yymsp[0].minor.yy6, NIL)); }
   53:  #line 842 "sexpr.c"
   54:          break;
   55:        case 5: /* sexpr ::= COMMA_AT sexpr */
   56: -#line 21 "sexpr.lmn"
   57: +#line 21 "sexpr.y"
   58:  { yymsp[-1].minor.yy6 = cons(sym_splice, cons(yymsp[0].minor.yy6, NIL)); }
   59:  #line 847 "sexpr.c"
   60:          break;
   61:        case 6: /* sexpr ::= COMMA sexpr */
   62: -#line 22 "sexpr.lmn"
   63: +#line 22 "sexpr.y"
   64:  { yymsp[-1].minor.yy6 = cons(sym_unquote, cons(yymsp[0].minor.yy6, NIL)); }
   65:  #line 852 "sexpr.c"
   66:          break;
   67:        case 7: /* sexpr ::= OPAREN sexpr DOT sexpr CPAREN */
   68: -#line 23 "sexpr.lmn"
   69: +#line 23 "sexpr.y"
   70:  { yymsp[-4].minor.yy6 = cons(yymsp[-3].minor.yy6,yymsp[-1].minor.yy6); }
   71:  #line 857 "sexpr.c"
   72:          break;
   73:        case 8: /* sexpr ::= OPAREN CPAREN */
   74: -#line 24 "sexpr.lmn"
   75: +#line 24 "sexpr.y"
   76:  { yymsp[-1].minor.yy6 = NIL; }
   77:  #line 862 "sexpr.c"
   78:          break;
   79:        case 10: /* list ::= OPAREN sexpr listelem CPAREN */
   80: -#line 27 "sexpr.lmn"
   81: +#line 27 "sexpr.y"
   82:  { yymsp[-3].minor.yy0 = cons(yymsp[-2].minor.yy6,yymsp[-1].minor.yy0); }
   83:  #line 867 "sexpr.c"
   84:          break;
   85:        case 11: /* listelem ::= sexpr listelem */
   86: -#line 29 "sexpr.lmn"
   87: +#line 29 "sexpr.y"
   88:  { yylhsminor.yy0 = cons(yymsp[-1].minor.yy6, yymsp[0].minor.yy0); }
   89:  #line 872 "sexpr.c"
   90:    yymsp[-1].minor.yy0 = yylhsminor.yy0;
   91:          break;
   92:        case 12: /* listelem ::= */
   93: -#line 30 "sexpr.lmn"
   94: +#line 30 "sexpr.y"
   95:  { yymsp[1].minor.yy0 = NIL; }
   96:  #line 878 "sexpr.c"
   97:          break;
   98: @@ -880,7 +880,7 @@ static void yy_reduce(
   99:        case 14: /* atom ::= STRING */ yytestcase(yyruleno==14);
  100:        case 15: /* atom ::= INTEGER */ yytestcase(yyruleno==15);
  101:        case 16: /* atom ::= NIHIL */ yytestcase(yyruleno==16);
  102: -#line 32 "sexpr.lmn"
  103: +#line 32 "sexpr.y"
  104:  { yylhsminor.yy0 = yymsp[0].minor.yy0; }
  105:  #line 886 "sexpr.c"
  106:    yymsp[0].minor.yy0 = yylhsminor.yy0;
  107: @@ -944,9 +944,9 @@ static void yy_syntax_error(
  108:    ParseARG_FETCH;
  109:  #define TOKEN yyminor
  110:  /************ Begin %syntax_error code ****************************************/
  111: -#line 8 "sexpr.lmn"
  112: +#line 8 "sexpr.y"
  113:  
  114: -	      printf("SYNTAX ERROR!\n");
  115: +  raise_exception("syntax error", NIL); 
  116:  #line 951 "sexpr.c"
  117:  /************ End %syntax_error code ******************************************/
  118:    ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
  119: diff --git a/src/lib/sexpr.y b/src/lib/sexpr.y
  120: index 4e61add..152ce46 100644
  121: --- a/src/lib/sexpr.y
  122: +++ b/src/lib/sexpr.y
  123: @@ -6,7 +6,7 @@
  124:  %extra_argument { struct parse_cb *cb }
  125:  
  126:  %syntax_error {
  127: -	      printf("SYNTAX ERROR!\n");
  128: +  raise_exception("syntax error", NIL); 
  129:  }
  130:  
  131:  input ::= sexprlist ENDPARSE.
  132: diff --git a/src/repl/lac.c b/src/repl/lac.c
  133: index 666408b..5937d88 100644
  134: --- a/src/repl/lac.c
  135: +++ b/src/repl/lac.c
  136: @@ -91,7 +91,7 @@ main (int argc, char *argv[])
  137:    null_env = lac_init ();
  138:    if (null_env == NULL)
  139:      {
  140: -      fprintf (stderr, "Initialization failed.");
  141: +      fprintf (stderr, "Initialization failed.\n");
  142:        return -1;
  143:      }
  144:    repl (stdin, stdout, stderr);

Generated by git2html.