%{ function ERR(yy, err){ console.log(err); yy.error.line = yy.line; yy.error.msg = err; throw "tantrum"; } function CHECKESCAPE(yy, str){ if(!"[]:@~\\\"".find(str)){ ERR(yy, "hmmlib: Unknown backslash escape code: %s", str); } } function UNQUOTE(yy, str){ var i = 0; var j = 0; while((j = str.indexOf('\\', i)) != -1){ CHECKESCAPE(yy, str.charAt(j)); str = str.slice(i, j) + str.slice(j+1); i = j+1; } return str; } function M_(yy, str, s){ yy.an.markers.push({ type: str }); yy.mnext = s; } function M_ADD(yy, t, n){ yy.an.markers[yy.an.markers.length - 1].marker = t.substr(0, n); yy.an.markers[yy.an.markers.length - 1].offset = yy.an.text.length; if(yy.mnext === "TEXT"){ yy.an.text += t.substr(0, n); } } function MX_ADD(yy, c){ var m = yy.an.markers[yy.an.markers.length - 1]; if(m.parameter){ m.parameter += c; } else { m.parameter = c; } yy.an.text += c; } function NEWANNO(yy){ if(!yy.first) yy.annos.push(yy.an); yy.an = { line: yy.line, time: "", text: "", author: "", references: [], markers: [], quote: { id: 0, author: "" }, is_quote: false }; yy.an.line = yy.line; yy.first = false; } %} %option reentrant %option noyywrap S [\t \r]* SP [\t \r]+ ATTR_SIMPLE [^\" \]\t\r\n][^ \]\t\r\n]* ATTR_ALNUM [0-9a-zA-Z][0-9a-zA-Z_]* ATTR_QUOTED \"([^\n\"\\]|\\.)*\" TAG_VIDEO_OPEN "[video" TIMECODE \[[0-9]{1,2}(\:[0-5][0-9]){1,2}\] BAD_TIMECODE \[[0-9]{1,2}(\:[6-9][0-9]){1,2}\] TEXT_BREAK [^\\\:\@\~\[\]\r\n\t ] LB \[ RB \] %s VIDEO %s V_ATTR %s ANNOTATION %s TEXT_START %s TEXT %s MARKER %s MARKER_XTRA %s REF %s R_ATTR %s AFTERTEXT %s AUTHOR %s CATEGORIES %s QUOTES %% <> { ERR(yy, "Unexpected EOF, video close tag not found."); } \r\n|\n { yy.line++; } {TAG_VIDEO_OPEN} { yy_.begin("VIDEO"); } . { ERR(yy, "Missing video tag."); }