/* .Y / 70 83 / / / / 105 / / / / / / ;A4_QUER.Y */ /* .YT 3 2 0 0 3 3 1 / / / */ /* .H!a!0:io#092/disk#092/mediaAccess#092/grammar#092/cpp#092/MediaInfo.l!0.!c */ /*************************************************************************** io disk mediaAccess grammar MediaInfo.l +++++++++++++++++++++++++++++++++++++++ purpose : specifies a lexical analizer for the grammar of a "mediaAccess"-media-info-structure (/-text) begin : Wed Apr 12 14:19:23 CEST 2017 changes : copyright : (C) 2017 by Thomas Bruecker email : public@thomas-r-bruecker.ch version : -0.0.0 ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU L E S S E R General Public License * * as published by the Free Software Foundation; either Version 2 of the * * License, or (at your option) any later Version. * * * * This program is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * L E S S E R General Public License for more details. * * * * You should have received a copy of the GNU L E S S E R General * * Public License along with this program; if not, write to the Free * * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * * MA 02110-1301 USA. * * * ***************************************************************************/ %{ #include "MediaInfo.h" #include "MediaInfo.tab.h" // #define DebugPrintF(...) printf(__VA_ARGS__) #define DebugPrintF(...) %} %option noyywrap COMMENT {_COMMENT0}|{_COMMENT1} CONSTANT {DecimalDigit}+ DecimalDigit [0-9] ELSE . HexDigit {DecimalDigit}|[A-F] HexDuoDectet {HexDigit}{12} HexOctet {HexDigit}{8} HexQuartet {HexDigit}{4} LF \n+ ParameterChar {DecimalDigit}|[A-Za-z]|_ ParameterName _{ParameterChar}*|[A-Za-z]{ParameterChar}* STRING '{TextChar}*'|\"{TextChar}*\" /* you may not match a string here, because it may be longer than an uuid. */ TextChar [^'^\n^\r^\t]|^ UUID {HexOctet}-{HexQuartet}-{HexQuartet}-{HexQuartet}-{HexDuoDectet} WhiteSpace [ \t]+ _COMMENT0 {WhiteSpace}*#{TextChar}*\n _COMMENT1 {_COMMENT1_0}{_COMMENT1_1} _COMMENT1_0 {WhiteSpace}*#{WhiteSpace}*{ParameterName} _COMMENT1_1 {TextChar}+{STRING}{TextChar}*\n %% {COMMENT} { DebugPrintF(" = \"%s\"\n", yytext); strcat(pLine, yytext); yylloc->last_column += strlen(yytext); yylloc->last_line++; *yylval = strdup(yytext); return COMMENT; } {CONSTANT} { DebugPrintF(" = \"%s\"\n", yytext); strcat(pLine, yytext); yylloc->last_column += strlen(yytext); *yylval = strdup(yytext); return CONSTANT; } {LF} { DebugPrintF( " = '%d'\n", strlen(yytext) ); pLine[0] = 0; yylloc->last_column = 0; yylloc->last_line += strlen(yytext); return LF; } /* {ParameterChar} { */ /* DebugPrintF(" = \"%s\"\n", yytext); yylval = yytext; return ParameterChar; */ /* } */ {ParameterName} { DebugPrintF(" = \"%s\"\n", yytext); strcat(pLine, yytext); yylloc->last_column += strlen(yytext); *yylval = strdup(yytext); return ParameterName; } {UUID} { DebugPrintF(" = \"%s\"\n", yytext); strcat(pLine, yytext); yylloc->last_column += strlen(yytext); *yylval = strdup(yytext); return UUID; } /* must be before "STRING" to match first uuids! */ {STRING} { DebugPrintF(" = \"%s\"\n", yytext); strcat(pLine, yytext); yylloc->last_column += strlen(yytext); *yylval = strdup(yytext); return STRING; } {WhiteSpace} { DebugPrintF("\n"); strcat(pLine, yytext); yylloc->last_column += strlen(yytext); return WhiteSpace; } {ELSE} { DebugPrintF(" = \"%s\"\n", yytext); strcat(pLine, yytext); yylloc->last_column++; return yytext[0]; } /* must be after everything to give the other rules a change to match! */ %%