]> khamidou — GitHub mirrors - miniforth.git/commitdiff
added a byte string feature master
authorkhamidou <khamidou@gmail.com>
Wed, 2 Mar 2011 10:44:41 +0000 (11:44 +0100)
committerkhamidou <khamidou@gmail.com>
Wed, 2 Mar 2011 10:44:41 +0000 (11:44 +0100)
as.c
aslexer.l
tokens.h

diff --git a/as.c b/as.c
index ae178850b1dd6c6f43d8c0a8b7def6eccbae001b..e57d63c35442ceba1501b475dfe948af640fad2b 100644 (file)
--- a/as.c
+++ b/as.c
@@ -87,8 +87,8 @@ int first_pass() {
                                t = yylex();
 
                                if (t != T_TIMES) 
-                                       fail("Expected a times keyword after db directive");
-
+                                       fail("Expected a times keyword or a string after db directive");
+                               
                                t = yylex();
 
                                if (t != NUMBER)
@@ -97,6 +97,10 @@ int first_pass() {
                                current_offset += atoi(yytext);
                                break;
 
+                       case STRING:
+                               current_offset += strlen(yytext);
+                               break;
+
 
                        default:
                                current_offset++;
@@ -218,8 +222,15 @@ int parse() {
 
                                for(i = 1; i <= max_iter; i++)
                                        writeint(val, outfp);
+                               
                                break;
+                                                       
+                       case STRING:
+                               /* output the string in raw form to the file */
+                               for(i = 0; i < strlen(yytext); i++)
+                                       writeint(yytext[i], outfp);
 
+                               break;
                        default:
                                fail("unexpected %s in input at line %d", yytext, yylineno);
                                break;
index 75c60ca2a80668176de13d01fd86a3833de3bfad..ac50eb11021ffca46257edfb893a4db12ed18ac3 100644 (file)
--- a/aslexer.l
+++ b/aslexer.l
@@ -31,5 +31,6 @@
 [0-9]+         { return NUMBER;        }
 [a-zA-Z][a-zA-Z0-9]*:  { return T_LABEL;       }
 [a-zA-Z][a-zA-Z0-9]*   { return WORD;  }
+\".+\"                 { return STRING;        }
 
 <<EOF>>                { return -1;            }
index 94826e429a7058f57aa2e61b7ce501f416b7a1e9..daa39f7adc0f7ad65dbef9850c21c48250a26c63 100644 (file)
--- a/tokens.h
+++ b/tokens.h
@@ -3,6 +3,7 @@
 
 enum tokens {  NUMBER, 
                WORD, 
+               STRING,
                T_LABEL, 
                T_PUSH, 
                T_POP,