diff lwbasic/parser.c @ 35:cdb0175e1063

More work on expressions
author Lost Wizard (lost@starbug3)
date Sat, 05 Feb 2011 14:22:54 -0700
parents bfea77812e64
children 5325b640424d
line wrap: on
line diff
--- a/lwbasic/parser.c	Fri Feb 04 21:27:03 2011 -0700
+++ b/lwbasic/parser.c	Sat Feb 05 14:22:54 2011 -0700
@@ -66,6 +66,14 @@
 	return pt;
 }
 
+static int parse_expression(cstate *state)
+{
+	state -> expression = 1;
+	
+	state -> expression = 0;
+	return 1;
+}
+
 static void parse_decls(cstate *state)
 {
 	/* declarations */
@@ -122,6 +130,7 @@
 static void parse_statements(cstate *state)
 {
 	symtab_entry_t *se;
+	int et;
 	
 	for (;;)
 	{
@@ -141,10 +150,14 @@
 			if (!se)
 				lwb_error("Unknown variable %s\n", state -> lexer_token_string);
 			lexer(state);
+			/* ensure the first token of the expression will be parsed correctly */
+			state -> expression = 1;
 			expect(state, token_op_assignment);
 
 			/* parse the expression */
-			/* parse_expression(state); */
+			et = parse_expression(state);
+			
+			/* check type compatibility */
 			
 			/* actually do the assignment */