aboutsummaryrefslogtreecommitdiffstats
path: root/edify/parser.y
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2009-06-12 12:24:39 -0700
committerDoug Zongker <dougz@android.com>2009-06-12 14:05:03 -0700
commitd9c9d10d9da76f067d3955bea71f7bb39e859fa5 (patch)
tree1e49a3a616c3147f871e79b1b15e2b2a63379cc1 /edify/parser.y
parent8edb00c990e563e6f91b278a212f2edf877cf763 (diff)
downloadbootable_recovery-d9c9d10d9da76f067d3955bea71f7bb39e859fa5.zip
bootable_recovery-d9c9d10d9da76f067d3955bea71f7bb39e859fa5.tar.gz
bootable_recovery-d9c9d10d9da76f067d3955bea71f7bb39e859fa5.tar.bz2
fixes to edify and updater script
A few more changes to edify: - fix write_raw_image(); my last change neglected to close the write context, so the written image was corrupt. - each expression tracks the span of the source code from which it was compiled, so that assert()'s error message can include the source of the expression that failed. - the 'cookie' argument to each Function is replaced with a State object, which contains the cookie, the source script (for use with the above spans), and the current error message (replacing the global variables that were used for this purpose). - in the recovery image, a new command "ui_print" can be sent back through the command pipe to cause text to appear on the screen. Add a new ui_print() function to print things from scripts. Rename existing "print" function to "stdout".
Diffstat (limited to 'edify/parser.y')
-rw-r--r--edify/parser.y31
1 files changed, 19 insertions, 12 deletions
diff --git a/edify/parser.y b/edify/parser.y
index cf163c0..3f9ade1 100644
--- a/edify/parser.y
+++ b/edify/parser.y
@@ -20,6 +20,7 @@
#include <string.h>
#include "expr.h"
+#include "yydefs.h"
#include "parser.h"
extern int gLine;
@@ -30,6 +31,8 @@ int yyparse(Expr** root, int* error_count);
%}
+%locations
+
%union {
char* str;
Expr* expr;
@@ -68,19 +71,21 @@ expr: STRING {
$$->name = $1;
$$->argc = 0;
$$->argv = NULL;
+ $$->start = @$.start;
+ $$->end = @$.end;
}
-| '(' expr ')' { $$ = $2; }
-| expr ';' { $$ = $1; }
-| expr ';' expr { $$ = Build(SequenceFn, 2, $1, $3); }
-| error ';' expr { $$ = $3; }
-| expr '+' expr { $$ = Build(ConcatFn, 2, $1, $3); }
-| expr EQ expr { $$ = Build(EqualityFn, 2, $1, $3); }
-| expr NE expr { $$ = Build(InequalityFn, 2, $1, $3); }
-| expr AND expr { $$ = Build(LogicalAndFn, 2, $1, $3); }
-| expr OR expr { $$ = Build(LogicalOrFn, 2, $1, $3); }
-| '!' expr { $$ = Build(LogicalNotFn, 1, $2); }
-| IF expr THEN expr ENDIF { $$ = Build(IfElseFn, 2, $2, $4); }
-| IF expr THEN expr ELSE expr ENDIF { $$ = Build(IfElseFn, 3, $2, $4, $6); }
+| '(' expr ')' { $$ = $2; $$->start=@$.start; $$->end=@$.end; }
+| expr ';' { $$ = $1; $$->start=@1.start; $$->end=@1.end; }
+| expr ';' expr { $$ = Build(SequenceFn, @$, 2, $1, $3); }
+| error ';' expr { $$ = $3; $$->start=@$.start; $$->end=@$.end; }
+| expr '+' expr { $$ = Build(ConcatFn, @$, 2, $1, $3); }
+| expr EQ expr { $$ = Build(EqualityFn, @$, 2, $1, $3); }
+| expr NE expr { $$ = Build(InequalityFn, @$, 2, $1, $3); }
+| expr AND expr { $$ = Build(LogicalAndFn, @$, 2, $1, $3); }
+| expr OR expr { $$ = Build(LogicalOrFn, @$, 2, $1, $3); }
+| '!' expr { $$ = Build(LogicalNotFn, @$, 1, $2); }
+| IF expr THEN expr ENDIF { $$ = Build(IfElseFn, @$, 2, $2, $4); }
+| IF expr THEN expr ELSE expr ENDIF { $$ = Build(IfElseFn, @$, 3, $2, $4, $6); }
| STRING '(' arglist ')' {
$$ = malloc(sizeof(Expr));
$$->fn = FindFunction($1);
@@ -93,6 +98,8 @@ expr: STRING {
$$->name = $1;
$$->argc = $3.argc;
$$->argv = $3.argv;
+ $$->start = @$.start;
+ $$->end = @$.end;
}
;