gstreamer_core/gst/parse/parse.l
changeset 2 5505e8908944
parent 0 0e761a78d257
child 8 4a7fac7dd34a
equal deleted inserted replaced
1:4c282e7dd6d3 2:5505e8908944
       
     1 %{
       
     2 
       
     3 #include <math.h>
       
     4 #include <string.h>
       
     5 
       
     6 #include <glib/gprintf.h>
       
     7 
       
     8 #include "../gst_private.h"
       
     9 
       
    10 #include "types.h"
       
    11 #include "../gstinfo.h"
       
    12 #include "../gsturi.h"
       
    13 #include "grammar.tab.h"
       
    14 
       
    15 #ifdef __SYMBIAN32__
       
    16 #include <glib_global.h>
       
    17 #include <gobject_global.h>
       
    18 #endif
       
    19 
       
    20 /* Override the default ECHO so as to avoid fortify warnings. Ignore the
       
    21    embedded-NUL case for now. We know yytext is NUL-terminated. */
       
    22 #define ECHO g_fprintf(yyout, "%s", yytext)
       
    23 
       
    24 #ifdef G_HAVE_ISO_VARARGS
       
    25 #define PRINT(...) GST_CAT_DEBUG (GST_CAT_PIPELINE, "flex: " __VA_ARGS__)
       
    26 #elif defined(G_HAVE_GNUC_VARARGS)
       
    27 #define PRINT(args...) GST_CAT_DEBUG (GST_CAT_PIPELINE, "flex: " args)
       
    28 #else
       
    29 static inline void
       
    30 PRINT (const char *format, ...)
       
    31 {
       
    32   va_list varargs;
       
    33 
       
    34   va_start (varargs, format);
       
    35   GST_CAT_LEVEL_LOG_valist (GST_CAT_PIPELINE, GST_LEVEL_DEBUG, NULL,
       
    36     format, varargs);
       
    37   va_end (varargs);
       
    38 }
       
    39 #endif
       
    40 
       
    41 %}
       
    42 
       
    43 _operator [(){}.!,;=]
       
    44 _identifier [[:alpha:]][[:alnum:]\-_%:]*
       
    45 
       
    46 _char ("\\".)|([^[:space:]])
       
    47 _string {_char}+|("\""([^\"]|"\\\"")*"\"")|("'"([^']|"\\\'")*"'")
       
    48 
       
    49 _assign [[:space:]]*"="[[:space:]]*
       
    50 
       
    51 _protocol [[:alpha:]][[:alnum:]+-\.]*
       
    52 _url ({_protocol}"://"{_string}|["."{_identifier}]?"/"{_string})|({_protocol}"://")
       
    53 
       
    54 /* we must do this here, because nearly everything matches a {_string} */ 
       
    55 _assignment {_identifier}{_assign}{_string}
       
    56 
       
    57 /* get pad/element references and stuff with dots right */
       
    58 _padref "."{_identifier}
       
    59 _ref {_identifier}"."{_identifier}?
       
    60 _binref {_identifier}[[:space:]]*"."[[:space:]]*"("
       
    61 
       
    62 /* links */
       
    63 _mimechar [[:alnum:]-]
       
    64 _mimetype {_mimechar}+"/"{_mimechar}+
       
    65 _capschar ("\\".)|([^\;!])
       
    66 _capsstring {_capschar}+
       
    67 _caps {_mimetype}(","[^!]|{_capsstring})*
       
    68 _link ("!"[[:space:]]*{_caps}([[:space:]]*(";"[[:space:]]*{_caps})*[[:space:]]*)*"!")|("!")
       
    69 
       
    70 %x value
       
    71 %option noyywrap
       
    72 %option nounput
       
    73 %option reentrant
       
    74 %option bison-bridge
       
    75 %option never-interactive
       
    76 %option noinput
       
    77 %%
       
    78 
       
    79 {_assignment} {
       
    80     /* "=" */
       
    81     PRINT ("ASSIGNMENT: %s", yytext);
       
    82     yylval->s = gst_parse_strdup (yytext);
       
    83     BEGIN (INITIAL);
       
    84     return ASSIGNMENT;
       
    85 }
       
    86 
       
    87 {_padref} {
       
    88     yytext++;
       
    89     PRINT ("PADREF: %s", yytext);
       
    90     yylval->s = gst_parse_strdup (yytext);
       
    91     BEGIN (INITIAL);
       
    92     return PADREF;
       
    93 }
       
    94 
       
    95 {_ref} {
       
    96     PRINT ("REF: %s", yytext);
       
    97     yylval->s = gst_parse_strdup (yytext);
       
    98     BEGIN (INITIAL);
       
    99     return REF;
       
   100 }
       
   101 
       
   102 {_binref} {
       
   103     gchar *pos = yytext;
       
   104     while (!g_ascii_isspace (*pos) && (*pos != '.')) pos++;
       
   105     *pos = '\0';
       
   106     PRINT ("BINREF: %s", yytext);
       
   107     yylval->s = gst_parse_strdup (yytext);
       
   108     BEGIN (INITIAL);
       
   109     return BINREF;
       
   110 }
       
   111 
       
   112 {_identifier} {
       
   113     PRINT ("IDENTIFIER: %s", yytext);
       
   114     yylval->s = gst_parse_strdup (yytext);
       
   115     BEGIN (INITIAL);
       
   116     return IDENTIFIER;
       
   117 }
       
   118 
       
   119 {_link} {
       
   120     gchar *c = yytext;
       
   121     PRINT ("LINK: %s", yytext);
       
   122     c++;
       
   123     if (*c) {
       
   124       while (g_ascii_isspace (*c)) c++;
       
   125       c = yylval->s = gst_parse_strdup (c);
       
   126       while (*c) c++;
       
   127       if (*--c != '!')
       
   128 	g_assert_not_reached ();
       
   129       while (g_ascii_isspace (*--c));
       
   130       *++c = '\0';
       
   131     } else {
       
   132       yylval->s = NULL;
       
   133     }
       
   134     BEGIN (INITIAL);
       
   135     return LINK;
       
   136 }
       
   137 {_url} {
       
   138   PRINT ("URL: %s", yytext);
       
   139   yylval->s = g_strdup (yytext);
       
   140   gst_parse_unescape (yylval->s);
       
   141   BEGIN (INITIAL);
       
   142   return PARSE_URL;
       
   143 }
       
   144 
       
   145 {_operator} { PRINT ("OPERATOR: [%s]", yytext); return *yytext; }
       
   146 
       
   147 [[:space:]]+ { PRINT ("SPACE: [%s]", yytext); }
       
   148 
       
   149 . {
       
   150     PRINT ("Invalid Lexer element: %s\n", yytext);
       
   151     return *yytext;
       
   152 }
       
   153 
       
   154 %%