HAAS Stereo Enhancer
[calf.git] / bigbull / ttl.l
blobbaba2b8352a2e4e6483e7bac1fd486a290602fac
1 %{
2 #include <Python.h>
3 #include "ttldata.h"
5 int yyFlexLexer::yywrap() { return 1; }
7 void yyerror(const char *str)
9     PyErr_SetString(PyExc_SyntaxError, str);
14 %x C_COMMENT C_LONGSTRING C_STRING
16 SYMBOL [A-Za-z_-][a-zA-Z0-9_-]*
17 TRIPLEQUOTE \"\"\"
21 @prefix { LEXER_DATA->add("prefix", "@prefix"); }
22 # BEGIN(C_COMMENT);
23 {TRIPLEQUOTE} { LEXER_DATA->strctx.clear(); BEGIN(C_LONGSTRING); }
24 \" { LEXER_DATA->strctx.clear(); BEGIN(C_STRING); }
25 \<[^>]*\> { LEXER_DATA->add("URI", std::string(yytext + 1, strlen(yytext) - 2)); }
26 [+-]?([0-9]+\.[0-9]*|\.[0-9]+)([eE][-+]?[0-9]+)? { std::stringstream ss(yytext); double value; ss >> value; LEXER_DATA->add("number", PyFloat_FromDouble(value)); }
27 [+-]?[0-9]+ { LEXER_DATA->add("number", PyInt_FromLong(atol(yytext))); }
28 {SYMBOL}?:{SYMBOL}? { LEXER_DATA->add("prnot", yytext); } 
29 {SYMBOL} { LEXER_DATA->add("symbol", yytext); } 
30 [.,;\[\]\(\)] { LEXER_DATA->add(yytext, yytext); } 
31 [ \t\n] ;
33 . { 
34     std::stringstream ss;
35     ss << "Unexpected characters: '" << yytext << "'" << std::endl;
36     PyErr_SetString(PyExc_ValueError, ss.str().c_str());
37     yyerror("Syntax error");
40 <C_LONGSTRING>{TRIPLEQUOTE} { LEXER_DATA->add("string", LEXER_DATA->strctx); BEGIN(INITIAL); }
41 <C_LONGSTRING>[^"]+ LEXER_DATA->strctx += yytext;
42 <C_LONGSTRING>\" LEXER_DATA->strctx += yytext;
44 <C_STRING>\" { LEXER_DATA->add("string", LEXER_DATA->strctx); BEGIN(INITIAL); }
45 <C_STRING>\\\" LEXER_DATA->strctx += "\""; 
46 <C_STRING>[^\\\"\n]+ LEXER_DATA->strctx += yytext;
48 <C_COMMENT>\n { BEGIN(INITIAL); }
49 <C_COMMENT>. ;