summaryrefslogtreecommitdiff
path: root/pidl/expr.yp
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-08-04 15:00:13 +0200
committerStefan Metzmacher <metze@samba.org>2009-08-07 11:50:24 +0200
commit20a6fb5cdb15b138021076e14c1df8f4ebb06184 (patch)
tree5a56f46fd50a570d237be4622a505aaf3d2080a9 /pidl/expr.yp
parentbfa9624946a35e5645effbb20e02abba2c34a8c2 (diff)
downloadsamba-20a6fb5cdb15b138021076e14c1df8f4ebb06184.tar.gz
pidl: fix formatting in expr.yp
metze
Diffstat (limited to 'pidl/expr.yp')
-rw-r--r--pidl/expr.yp202
1 files changed, 127 insertions, 75 deletions
diff --git a/pidl/expr.yp b/pidl/expr.yp
index a8074875ff9..ef8eee36dbf 100644
--- a/pidl/expr.yp
+++ b/pidl/expr.yp
@@ -2,70 +2,120 @@
# Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL
#
-%left '->'
-%right '!' '~'
-%left '*' '/' '%'
-%left '+' '-'
+%left '->'
+%right '!' '~'
+%left '*' '/' '%'
+%left '+' '-'
%left '<<' '>>'
-%left '>' '<'
-%left '==' '!='
-%left '&'
-%left '|'
-%left '&&'
-%left '||'
+%left '>' '<'
+%left '==' '!='
+%left '&'
+%left '|'
+%left '&&'
+%left '||'
%left '?' ':'
-%left NEG DEREF ADDROF INV
-%left '.'
+%left NEG DEREF ADDROF INV
+%left '.'
%%
-exp: NUM
- | TEXT { "\"$_[1]\"" }
- | func
- | var
- | '~' exp %prec INV { "~$_[2]" }
- | exp '+' exp { "$_[1] + $_[3]" }
- | exp '-' exp { "$_[1] - $_[3]" }
- | exp '*' exp { "$_[1] * $_[3]" }
- | exp '%' exp { "$_[1] % $_[3]" }
- | exp '<' exp { "$_[1] < $_[3]" }
- | exp '>' exp { "$_[1] > $_[3]" }
- | exp '|' exp { "$_[1] | $_[3]" }
- | exp '==' exp { "$_[1] == $_[3]" }
- | exp '<=' exp { "$_[1] <= $_[3]" }
- | exp '=>' exp { "$_[1] => $_[3]" }
- | exp '<<' exp { "$_[1] << $_[3]" }
- | exp '>>' exp { "$_[1] >> $_[3]" }
- | exp '!=' exp { "$_[1] != $_[3]" }
- | exp '||' exp { "$_[1] || $_[3]" }
- | exp '&&' exp { "$_[1] && $_[3]" }
- | exp '&' exp { "$_[1] & $_[3]" }
- | exp '?' exp ':' exp { "$_[1]?$_[3]:$_[5]" }
- | '~' exp { "~$_[1]" }
- | '!' exp { "not $_[1]" }
- | exp '/' exp { "$_[1] / $_[3]" }
- | '-' exp %prec NEG { "-$_[2]" }
- | '&' exp %prec ADDROF { "&$_[2]" }
- | exp '^' exp { "$_[1]^$_[3]" }
- | '(' exp ')' { "($_[2])" }
+exp:
+ NUM
+ |
+ TEXT { "\"$_[1]\"" }
+ |
+ func
+ |
+ var
+ |
+ '~' exp %prec INV { "~$_[2]" }
+ |
+ exp '+' exp { "$_[1] + $_[3]" }
+ |
+ exp '-' exp { "$_[1] - $_[3]" }
+ |
+ exp '*' exp { "$_[1] * $_[3]" }
+ |
+ exp '%' exp { "$_[1] % $_[3]" }
+ |
+ exp '<' exp { "$_[1] < $_[3]" }
+ |
+ exp '>' exp { "$_[1] > $_[3]" }
+ |
+ exp '|' exp { "$_[1] | $_[3]" }
+ |
+ exp '==' exp { "$_[1] == $_[3]" }
+ |
+ exp '<=' exp { "$_[1] <= $_[3]" }
+ |
+ exp '=>' exp { "$_[1] => $_[3]" }
+ |
+ exp '<<' exp { "$_[1] << $_[3]" }
+ |
+ exp '>>' exp { "$_[1] >> $_[3]" }
+ |
+ exp '!=' exp { "$_[1] != $_[3]" }
+ |
+ exp '||' exp { "$_[1] || $_[3]" }
+ |
+ exp '&&' exp { "$_[1] && $_[3]" }
+ |
+ exp '&' exp { "$_[1] & $_[3]" }
+ |
+ exp '?' exp ':' exp { "$_[1]?$_[3]:$_[5]" }
+ |
+ '~' exp { "~$_[1]" }
+ |
+ '!' exp { "not $_[1]" }
+ |
+ exp '/' exp { "$_[1] / $_[3]" }
+ |
+ '-' exp %prec NEG { "-$_[2]" }
+ |
+ '&' exp %prec ADDROF { "&$_[2]" }
+ |
+ exp '^' exp { "$_[1]^$_[3]" }
+ |
+ '(' exp ')' { "($_[2])" }
;
-possible_pointer:
- VAR { $_[0]->_Lookup($_[1]) }
- | '*' possible_pointer %prec DEREF { $_[0]->_Dereference($_[2]); "*$_[2]" }
- ;
+possible_pointer:
+ VAR { $_[0]->_Lookup($_[1]) }
+ |
+ '*' possible_pointer %prec DEREF { $_[0]->_Dereference($_[2]); "*$_[2]" }
+;
+
+var:
+ possible_pointer { $_[0]->_Use($_[1]) }
+ |
+ var '.' VAR { $_[0]->_Use("$_[1].$_[3]") }
+ |
+ '(' var ')' { "($_[2])" }
+ |
+ var '->' VAR { $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
+;
+
+
+func:
+ VAR '(' opt_args ')' { "$_[1]($_[3])" }
+;
-var: possible_pointer { $_[0]->_Use($_[1]) }
- | var '.' VAR { $_[0]->_Use("$_[1].$_[3]") }
- | '(' var ')' { "($_[2])" }
- | var '->' VAR { $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
+opt_args:
+ #empty
+ { "" }
+ |
+ args
;
+exp_or_possible_pointer:
+ exp
+ |
+ possible_pointer
+;
-func: VAR '(' opt_args ')' { "$_[1]($_[3])" };
-opt_args: { "" } | args;
-exp_or_possible_pointer: exp | possible_pointer;
-args: exp_or_possible_pointer
- | exp_or_possible_pointer ',' args { "$_[1], $_[3]" }
+args:
+ exp_or_possible_pointer
+ |
+ exp_or_possible_pointer ',' args { "$_[1], $_[3]" }
;
%%
@@ -73,22 +123,22 @@ args: exp_or_possible_pointer
package Parse::Pidl::Expr;
sub _Lexer {
- my($parser)=shift;
+ my($parser)=shift;
- $parser->YYData->{INPUT}=~s/^[ \t]//;
+ $parser->YYData->{INPUT}=~s/^[ \t]//;
- for ($parser->YYData->{INPUT}) {
- if (s/^(0x[0-9A-Fa-f]+)//) {
+ for ($parser->YYData->{INPUT}) {
+ if (s/^(0x[0-9A-Fa-f]+)//) {
$parser->YYData->{LAST_TOKEN} = $1;
- return('NUM',$1);
+ return('NUM',$1);
}
- if (s/^([0-9]+(?:\.[0-9]+)?)//) {
+ if (s/^([0-9]+(?:\.[0-9]+)?)//) {
$parser->YYData->{LAST_TOKEN} = $1;
- return('NUM',$1);
+ return('NUM',$1);
}
- if (s/^([A-Za-z_][A-Za-z0-9_]*)//) {
+ if (s/^([A-Za-z_][A-Za-z0-9_]*)//) {
$parser->YYData->{LAST_TOKEN} = $1;
- return('VAR',$1);
+ return('VAR',$1);
}
if (s/^\"(.*?)\"//) {
$parser->YYData->{LAST_TOKEN} = $1;
@@ -96,13 +146,13 @@ sub _Lexer {
}
if (s/^(==|!=|<=|>=|->|\|\||<<|>>|&&)//s) {
$parser->YYData->{LAST_TOKEN} = $1;
- return($1,$1);
+ return($1,$1);
}
- if (s/^(.)//s) {
+ if (s/^(.)//s) {
$parser->YYData->{LAST_TOKEN} = $1;
- return($1,$1);
+ return($1,$1);
}
- }
+ }
}
sub _Use($$)
@@ -139,12 +189,14 @@ sub _Error($)
}
sub Run {
- my($self, $data, $error, $lookup, $deref, $use) = @_;
- $self->YYData->{FULL_INPUT} = $data;
- $self->YYData->{INPUT} = $data;
- $self->YYData->{LOOKUP} = $lookup;
- $self->YYData->{DEREFERENCE} = $deref;
- $self->YYData->{ERROR} = $error;
- $self->YYData->{USE} = $use;
- return $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error);
+ my($self, $data, $error, $lookup, $deref, $use) = @_;
+
+ $self->YYData->{FULL_INPUT} = $data;
+ $self->YYData->{INPUT} = $data;
+ $self->YYData->{LOOKUP} = $lookup;
+ $self->YYData->{DEREFERENCE} = $deref;
+ $self->YYData->{ERROR} = $error;
+ $self->YYData->{USE} = $use;
+
+ return $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error);
}