From 154d8ae08733a83bfe0a314d0e4492697eebb143 Mon Sep 17 00:00:00 2001 From: Luis Ontanon Date: Sat, 1 Oct 2005 15:19:36 +0000 Subject: one step further... TPG now uses the ignore feature of tvbparse named sub_rules can have cardinality epan/tvbparse.c: do not crash on zero cardinality svn path=/trunk/; revision=16065 --- tools/tpg/tpg.yp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tools/tpg') diff --git a/tools/tpg/tpg.yp b/tools/tpg/tpg.yp index 983d587d3f..98b7e9556c 100644 --- a/tools/tpg/tpg.yp +++ b/tools/tpg/tpg.yp @@ -50,10 +50,16 @@ sub from_to { $b; } + +sub to_hexesc { + sprintf "\\x%.2x", unpack("C",$_[0]); +} + sub chars_control { $_ = $_[0]; s/([a-zA-Z0-9])-([a-zA-Z0-9])/from_to($1,$2)/ge; s/"/\\"/g; + s/\\(.)/to_hexesc($1)/ge; "\"$_\""; } @@ -113,6 +119,13 @@ statement: abort($_[0],"%value_string $name already defined") if exists ${${$parser_info}{vs}}{$name}; ${${$parser_info}{vs}}{$name} = $_[1]; } + | ignore_statement { + ${$parser_info}{ignore} = $_[1]; + } + ; + +ignore_statement: + '%ignore' LOWERCASE {$_[2]} ; rule_statement: @@ -151,7 +164,7 @@ tree: complete_rule: base_rule cardinality qualification {hj($_[1],hj($_[2],$_[3]))} - | named_rule + | named_rule cardinality { hj($_[1],$_[2]) } | until_rule ; -- cgit v1.2.1