diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-01-05 15:20:23 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:36:53 -0500 |
commit | e2b62f7d4168b5900dbaeadf4d4061abf6c1bd7c (patch) | |
tree | 1c353bd883dcc2c9a7d2927dca3b2e7de21169e4 /source4/pidl/idl.yp | |
parent | 0221d44ef4b62101d61a5275dab914c96ad326ee (diff) | |
download | samba-e2b62f7d4168b5900dbaeadf4d4061abf6c1bd7c.tar.gz samba-e2b62f7d4168b5900dbaeadf4d4061abf6c1bd7c.tar.bz2 samba-e2b62f7d4168b5900dbaeadf4d4061abf6c1bd7c.zip |
r20550: Use standard error mechanism in parser.
Make sure errors are reported correctly.
(This used to be commit 9f794c55a60b09536d6e0dbadfc172e1e74497ff)
Diffstat (limited to 'source4/pidl/idl.yp')
-rw-r--r-- | source4/pidl/idl.yp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/source4/pidl/idl.yp b/source4/pidl/idl.yp index 57061800b6..3030348c5c 100644 --- a/source4/pidl/idl.yp +++ b/source4/pidl/idl.yp @@ -26,21 +26,21 @@ idl: import: 'import' commalist ';' {{ "TYPE" => "IMPORT", "PATHS" => $_[2], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE} }} ; include: 'include' commalist ';' {{ "TYPE" => "INCLUDE", "PATHS" => $_[2], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE} }} ; importlib: 'importlib' commalist ';' {{ "TYPE" => "IMPORTLIB", "PATHS" => $_[2], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE} }} ; @@ -56,7 +56,7 @@ coclass: property_list 'coclass' identifier '{' interface_names '}' optional_sem "PROPERTIES" => $_[1], "NAME" => $_[3], "DATA" => $_[5], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; @@ -73,7 +73,7 @@ interface: property_list 'interface' identifier base_interface '{' definitions ' "NAME" => $_[3], "BASE" => $_[4], "DATA" => $_[6], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; @@ -99,7 +99,7 @@ const: 'const' identifier pointers identifier '=' anytext ';' "POINTERS" => $_[3], "NAME" => $_[4], "VALUE" => $_[6], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} | 'const' identifier pointers identifier array_len '=' anytext ';' @@ -110,7 +110,7 @@ const: 'const' identifier pointers identifier '=' anytext ';' "NAME" => $_[4], "ARRAY_LEN" => $_[5], "VALUE" => $_[7], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; @@ -123,7 +123,7 @@ function: property_list type identifier '(' element_list2 ')' ';' "RETURN_TYPE" => $_[2], "PROPERTIES" => $_[1], "ELEMENTS" => $_[5], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; @@ -134,7 +134,7 @@ declare: 'declare' property_list decl_type identifier';' "PROPERTIES" => $_[2], "NAME" => $_[4], "DATA" => $_[3], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; @@ -167,7 +167,7 @@ typedef: 'typedef' property_list type identifier array_len ';' "NAME" => $_[4], "DATA" => $_[3], "ARRAY_LEN" => $_[5], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; @@ -242,7 +242,7 @@ empty_element: property_list ';' "PROPERTIES" => $_[1], "POINTERS" => 0, "ARRAY_LEN" => [], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; @@ -276,7 +276,7 @@ base_element: property_list type pointers identifier array_len "PROPERTIES" => $_[1], "POINTERS" => $_[3], "ARRAY_LEN" => $_[5], - "FILE" => $_[0]->YYData->{INPUT_FILENAME}, + "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; @@ -374,6 +374,8 @@ optional_semicolon: # start code %% +use Parse::Pidl qw(error); + ##################################################################### # flatten an array of hashes into a single hash sub FlattenHash($) @@ -420,15 +422,13 @@ sub CleanData($) sub _Error { if (exists $_[0]->YYData->{ERRMSG}) { - print $_[0]->YYData->{ERRMSG}; + error($_[0]->YYData, $_[0]->YYData->{ERRMSG}); delete $_[0]->YYData->{ERRMSG}; return; }; - my $line = $_[0]->YYData->{LINE}; my $last_token = $_[0]->YYData->{LAST_TOKEN}; - my $file = $_[0]->YYData->{INPUT_FILENAME}; - print "$file:$line: Syntax error near '$last_token'\n"; + error($_[0]->YYData, "Syntax error near '$last_token'"); } sub _Lexer($) @@ -444,12 +444,12 @@ again: if (/^\#/) { if (s/^\# (\d+) \"(.*?)\"( \d+|)//) { $parser->YYData->{LINE} = $1-1; - $parser->YYData->{INPUT_FILENAME} = $2; + $parser->YYData->{FILE} = $2; goto again; } if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) { $parser->YYData->{LINE} = $1-1; - $parser->YYData->{INPUT_FILENAME} = $2; + $parser->YYData->{FILE} = $2; goto again; } if (s/^(\#.*)$//m) { @@ -491,7 +491,7 @@ sub parse_string my $self = new Parse::Pidl::IDL; - $self->YYData->{INPUT_FILENAME} = $filename; + $self->YYData->{FILE} = $filename; $self->YYData->{INPUT} = $data; $self->YYData->{LINE} = 0; $self->YYData->{LAST_TOKEN} = "NONE"; |