diff lwasm/lwasm.c @ 399:6153cb49403c

Initial commit of pragma newsource pragma newsource enables a source code variant as follows: 1. no line numbers 2. no implied comments at the end of lines 3. all comments must be introduced by a comment character 4. spaces are allowed in operands (4) is not quite complete. This commit handles "operandless" instructions (anything where the parser calls skip_operand()) and expression parsing.
author William Astle <lost@l-w.ca>
date Tue, 13 Oct 2015 23:38:02 -0600
parents f813a56178c0
children f8e56377a32a
line wrap: on
line diff
--- a/lwasm/lwasm.c	Sun Oct 11 09:31:06 2015 -0600
+++ b/lwasm/lwasm.c	Tue Oct 13 23:38:02 2015 -0600
@@ -32,6 +32,15 @@
 #include "lwasm.h"
 #include "instab.h"
 
+void lwasm_skip_to_next_token(line_t *cl, char **p)
+{
+	if (CURPRAGMA(cl, PRAGMA_NEWSOURCE))
+	{
+		for (; **p && isspace(**p); (*p)++)
+			/* do nothing */ ;
+	}
+}
+
 int lwasm_expr_exportable(asmstate_t *as, lw_expr_t expr)
 {
 	return 0;
@@ -869,13 +878,20 @@
 	if (as->exprwidth != 16)	
 	{
 		lw_expr_setwidth(as->exprwidth);
-		e = lw_expr_parse(p, as);
+		if (CURPRAGMA(as -> cl, PRAGMA_NEWSOURCE))
+			e = lw_expr_parse(p, as);
+		else
+			e = lw_expr_parse_compact(p, as);
 		lw_expr_setwidth(0);
 	}
 	else
 	{
-		e = lw_expr_parse(p, as);
+		if (CURPRAGMA(as -> cl, PRAGMA_NEWSOURCE))
+			e = lw_expr_parse(p, as);
+		else
+			e = lw_expr_parse_compact(p, as);
 	}
+	lwasm_skip_to_next_token(as -> cl, p);
 	return e;
 }
 
@@ -921,8 +937,10 @@
 	return NULL;
 }
 
-void skip_operand(char **p)
+void skip_operand_real(line_t *cl, char **p)
 {
+	if (CURPRAGMA(cl, PRAGMA_NEWSOURCE))
+		return;
 	for (; **p && !isspace(**p); (*p)++)
 		/* do nothing */ ;
 }