diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2006-05-02 14:26:17 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2006-05-02 14:26:17 +0000 |
commit | e3899ed4a43f006d51724d1fa05be20050968bd1 (patch) | |
tree | 3b6937dd3cfc7e7374855f1142c0bfcea1b1c49f /epan/dfilter/grammar.lemon | |
parent | 7edd136c889356810028c6fb291d8db69298beab (diff) |
Add infrastructure for display filter functions.
Add upper() and lower() display filter functions for string fields.
svn path=/trunk/; revision=18071
Diffstat (limited to 'epan/dfilter/grammar.lemon')
-rw-r--r-- | epan/dfilter/grammar.lemon | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/epan/dfilter/grammar.lemon b/epan/dfilter/grammar.lemon index 08169369c2..225dd73110 100644 --- a/epan/dfilter/grammar.lemon +++ b/epan/dfilter/grammar.lemon @@ -9,6 +9,7 @@ #include "syntax-tree.h" #include "sttype-range.h" #include "sttype-test.h" +#include "sttype-function.h" #include "drange.h" #include "grammar.h" @@ -51,6 +52,9 @@ %type drnode_list {GSList*} %destructor drnode_list {drange_node_free_list($$);} +%type funcparams {GSList*} +%destructor funcparams {st_funcparams_free($$);} + /* This is called as soon as a syntax error happens. After that, any "error" symbols are shifted, if possible. */ %syntax_error { @@ -85,6 +89,9 @@ any "error" symbols are shifted, if possible. */ hfinfo = stnode_data(TOKEN); dfilter_fail("Syntax error near \"%s\".", hfinfo->abbrev); break; + case STTYPE_FUNCTION: + dfilter_fail("The function s was unexpected in this context."); + break; /* These aren't handed to use as terminal tokens from the scanner, so was can assert that we'll never @@ -120,11 +127,6 @@ sentence ::= . { dfw->st_root = NULL; } expr(X) ::= relation_test(R). { X = R; } expr(X) ::= logical_test(L). { X = L; } -expr(X) ::= LPAREN expr(Y) RPAREN. -{ - X = Y; -} - /* Logical tests */ logical_test(T) ::= expr(E) TEST_AND expr(F). @@ -254,4 +256,35 @@ rel_op2(O) ::= TEST_CONTAINS. { O = TEST_OP_CONTAINS; } rel_op2(O) ::= TEST_MATCHES. { O = TEST_OP_MATCHES; } +/* Functions */ + +/* A function can have one or more parameters */ +entity(E) ::= FUNCTION(F) LPAREN funcparams(P) RPAREN. +{ + E = F; + sttype_function_set_params(E, P); +} + +/* A function can have zero parameters. */ +entity(E) ::= FUNCTION(F) LPAREN RPAREN. +{ + E = F; +} + +funcparams(P) ::= entity(E). +{ + P = g_slist_append(NULL, E); +} + +funcparams(P) ::= funcparams(L) COMMA entity(E). +{ + P = g_slist_append(L, E); +} + + +/* Any expression inside parens is simply that expression */ +expr(X) ::= LPAREN expr(Y) RPAREN. +{ + X = Y; +} |