- Timestamp:
- 04/11/14 23:37:17 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/vm/framscript.l
r163 r221 11 11 #define YY_NEVER_INTERACTIVE 1 12 12 13 static SString quoteDoubleQuotes(const SString &src); 14 13 15 %} 14 16 … … 17 19 %x asmcode2 18 20 %x comment 21 %x heredoc 19 22 20 23 %% … … 28 31 "null" {framscriptlval.setEmpty(); return CONSTANT;} 29 32 \"([^\\\"]|\\.)*\" {framscriptlval.setString(SString(yytext+1,yyleng-2));return CONSTANT;} 33 "<<<".*\n {trctx.herelimit=SString(yytext+3,yyleng-4); trctx.tmp=""; BEGIN heredoc; } 30 34 "@line "[0-9]+\n {trctx.line=atol(yytext+6);} 31 35 "@file "[^\n\t\r]+\n {trctx.srcname=SString(yytext+6,yyleng-7);} … … 67 71 <comment>\*\/ BEGIN 0; 68 72 <comment>. ; 69 73 <heredoc>[^\n]*\n { 74 trctx.line++; 75 SString tmp(yytext,yyleng-1); 76 if (tmp==trctx.herelimit) 77 { framscriptlval.setString(quoteDoubleQuotes(trctx.tmp)); BEGIN 0; return CONSTANT;} 78 else 79 { trctx.tmp+=tmp; trctx.tmp+="\n";} 80 } 70 81 [ \t\r\f] ; 71 82 \n {trctx.line++;} … … 90 101 91 102 %% 103 104 //exclusively for heredoc, but it should not be needed, there is some unexpected difference between quoting \n and \" in framscript parsing (TODO) 105 static SString quoteDoubleQuotes(const SString &src) 106 { 107 int len=src.len(); 108 SString ret((len*11)/10+10); 109 const char*t=(const char*)src; 110 while(len>0) 111 { 112 if (*t=='\"') 113 ret+="\\\""; 114 else 115 ret+=*t; 116 t++; len--; 117 } 118 return ret; 119 } 120 92 121 void framscript_init_lex() 93 122 {
Note: See TracChangeset
for help on using the changeset viewer.