added ratio to put commands
[swftools.git] / src / parser.lex
index beca943..e03175a 100644 (file)
@@ -3,7 +3,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "q.h"
+#include "../lib/q.h"
 #include "parser.h"
 
 //RVALUE        {NUMBER}|{PERCENT}|{NAME}|\"{STRING}\"|{DIM}
@@ -88,8 +88,8 @@ static void store(enum type_t type, int line, int column, char*text, int length)
            }
            prefix = 0;
        break;
-       case LABEL:
-           string_set2(&tmp, text, length-1);
+       case RAWDATA:
+           string_set2(&tmp, text+1/*:*/, length-5/*.end*/);
            token.text = (char*)mem_putstring(&strings, tmp);
        break;
        case COMMAND:
@@ -163,8 +163,8 @@ void handleInclude(char*text, int len)
 %x BINARY
 
 NAME    [a-zA-Z_./](-*[a-zA-Z0-9_./])*
-TWIP    ([0-9]+(\.([0-9]([05])?)?)?)
-NUMBER  [0-9]+(\.[0-9]*)?
+TWIP    (-?[0-9]+(\.([0-9]([05])?)?)?)
+NUMBER  -?[0-9]+(\.[0-9]*)?
 PERCENT         {NUMBER}%
 STRING   (\\.|[^\\"\n])*
 S       [ \n\r\t]
@@ -189,7 +189,7 @@ RVALUE       \"{STRING}\"|([^ \n\r\t]+)
 }
 \.include{S}.*\n                   {handleInclude(yytext, yyleng);}
 \.{NAME}                   {s(COMMAND);c();}
-{NAME}{S}*:                 {s(LABEL);c();}
+:([^.]|\.[^e]|\.e[^n]|\.en[^d]|[ \n\r\t])*\.end            {s(RAWDATA);c();}
 {NAME}                      {s(IDENTIFIER);c();}
 "["                        {c();BEGIN(BINARY);}
 {S}                        {c();}