summaryrefslogtreecommitdiff
path: root/pidl
diff options
context:
space:
mode:
Diffstat (limited to 'pidl')
-rw-r--r--pidl/expr.yp202
-rw-r--r--pidl/lib/Parse/Pidl/Expr.pm116
2 files changed, 186 insertions, 132 deletions
diff --git a/pidl/expr.yp b/pidl/expr.yp
index a8074875ff..ef8eee36db 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);
}
diff --git a/pidl/lib/Parse/Pidl/Expr.pm b/pidl/lib/Parse/Pidl/Expr.pm
index 5524374fae..1230a71a2b 100644
--- a/pidl/lib/Parse/Pidl/Expr.pm
+++ b/pidl/lib/Parse/Pidl/Expr.pm
@@ -1127,7 +1127,7 @@ sub new {
[#Rule 2
'exp', 1,
sub
-#line 22 "./pidl/expr.yp"
+#line 24 "./../pidl/expr.yp"
{ "\"$_[1]\"" }
],
[#Rule 3
@@ -1139,199 +1139,199 @@ sub
[#Rule 5
'exp', 2,
sub
-#line 25 "./pidl/expr.yp"
+#line 30 "./../pidl/expr.yp"
{ "~$_[2]" }
],
[#Rule 6
'exp', 3,
sub
-#line 26 "./pidl/expr.yp"
+#line 32 "./../pidl/expr.yp"
{ "$_[1] + $_[3]" }
],
[#Rule 7
'exp', 3,
sub
-#line 27 "./pidl/expr.yp"
+#line 34 "./../pidl/expr.yp"
{ "$_[1] - $_[3]" }
],
[#Rule 8
'exp', 3,
sub
-#line 28 "./pidl/expr.yp"
+#line 36 "./../pidl/expr.yp"
{ "$_[1] * $_[3]" }
],
[#Rule 9
'exp', 3,
sub
-#line 29 "./pidl/expr.yp"
+#line 38 "./../pidl/expr.yp"
{ "$_[1] % $_[3]" }
],
[#Rule 10
'exp', 3,
sub
-#line 30 "./pidl/expr.yp"
+#line 40 "./../pidl/expr.yp"
{ "$_[1] < $_[3]" }
],
[#Rule 11
'exp', 3,
sub
-#line 31 "./pidl/expr.yp"
+#line 42 "./../pidl/expr.yp"
{ "$_[1] > $_[3]" }
],
[#Rule 12
'exp', 3,
sub
-#line 32 "./pidl/expr.yp"
+#line 44 "./../pidl/expr.yp"
{ "$_[1] | $_[3]" }
],
[#Rule 13
'exp', 3,
sub
-#line 33 "./pidl/expr.yp"
+#line 46 "./../pidl/expr.yp"
{ "$_[1] == $_[3]" }
],
[#Rule 14
'exp', 3,
sub
-#line 34 "./pidl/expr.yp"
+#line 48 "./../pidl/expr.yp"
{ "$_[1] <= $_[3]" }
],
[#Rule 15
'exp', 3,
sub
-#line 35 "./pidl/expr.yp"
+#line 50 "./../pidl/expr.yp"
{ "$_[1] => $_[3]" }
],
[#Rule 16
'exp', 3,
sub
-#line 36 "./pidl/expr.yp"
+#line 52 "./../pidl/expr.yp"
{ "$_[1] << $_[3]" }
],
[#Rule 17
'exp', 3,
sub
-#line 37 "./pidl/expr.yp"
+#line 54 "./../pidl/expr.yp"
{ "$_[1] >> $_[3]" }
],
[#Rule 18
'exp', 3,
sub
-#line 38 "./pidl/expr.yp"
+#line 56 "./../pidl/expr.yp"
{ "$_[1] != $_[3]" }
],
[#Rule 19
'exp', 3,
sub
-#line 39 "./pidl/expr.yp"
+#line 58 "./../pidl/expr.yp"
{ "$_[1] || $_[3]" }
],
[#Rule 20
'exp', 3,
sub
-#line 40 "./pidl/expr.yp"
+#line 60 "./../pidl/expr.yp"
{ "$_[1] && $_[3]" }
],
[#Rule 21
'exp', 3,
sub
-#line 41 "./pidl/expr.yp"
+#line 62 "./../pidl/expr.yp"
{ "$_[1] & $_[3]" }
],
[#Rule 22
'exp', 5,
sub
-#line 42 "./pidl/expr.yp"
+#line 64 "./../pidl/expr.yp"
{ "$_[1]?$_[3]:$_[5]" }
],
[#Rule 23
'exp', 2,
sub
-#line 43 "./pidl/expr.yp"
+#line 66 "./../pidl/expr.yp"
{ "~$_[1]" }
],
[#Rule 24
'exp', 2,
sub
-#line 44 "./pidl/expr.yp"
+#line 68 "./../pidl/expr.yp"
{ "not $_[1]" }
],
[#Rule 25
'exp', 3,
sub
-#line 45 "./pidl/expr.yp"
+#line 70 "./../pidl/expr.yp"
{ "$_[1] / $_[3]" }
],
[#Rule 26
'exp', 2,
sub
-#line 46 "./pidl/expr.yp"
+#line 72 "./../pidl/expr.yp"
{ "-$_[2]" }
],
[#Rule 27
'exp', 2,
sub
-#line 47 "./pidl/expr.yp"
+#line 74 "./../pidl/expr.yp"
{ "&$_[2]" }
],
[#Rule 28
'exp', 3,
sub
-#line 48 "./pidl/expr.yp"
+#line 76 "./../pidl/expr.yp"
{ "$_[1]^$_[3]" }
],
[#Rule 29
'exp', 3,
sub
-#line 49 "./pidl/expr.yp"
+#line 78 "./../pidl/expr.yp"
{ "($_[2])" }
],
[#Rule 30
'possible_pointer', 1,
sub
-#line 53 "./pidl/expr.yp"
+#line 82 "./../pidl/expr.yp"
{ $_[0]->_Lookup($_[1]) }
],
[#Rule 31
'possible_pointer', 2,
sub
-#line 54 "./pidl/expr.yp"
+#line 84 "./../pidl/expr.yp"
{ $_[0]->_Dereference($_[2]); "*$_[2]" }
],
[#Rule 32
'var', 1,
sub
-#line 57 "./pidl/expr.yp"
+#line 88 "./../pidl/expr.yp"
{ $_[0]->_Use($_[1]) }
],
[#Rule 33
'var', 3,
sub
-#line 58 "./pidl/expr.yp"
+#line 90 "./../pidl/expr.yp"
{ $_[0]->_Use("$_[1].$_[3]") }
],
[#Rule 34
'var', 3,
sub
-#line 59 "./pidl/expr.yp"
+#line 92 "./../pidl/expr.yp"
{ "($_[2])" }
],
[#Rule 35
'var', 3,
sub
-#line 60 "./pidl/expr.yp"
+#line 94 "./../pidl/expr.yp"
{ $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
],
[#Rule 36
'func', 4,
sub
-#line 64 "./pidl/expr.yp"
+#line 99 "./../pidl/expr.yp"
{ "$_[1]($_[3])" }
],
[#Rule 37
'opt_args', 0,
sub
-#line 65 "./pidl/expr.yp"
+#line 104 "./../pidl/expr.yp"
{ "" }
],
[#Rule 38
@@ -1349,7 +1349,7 @@ sub
[#Rule 42
'args', 3,
sub
-#line 68 "./pidl/expr.yp"
+#line 118 "./../pidl/expr.yp"
{ "$_[1], $_[3]" }
]
],
@@ -1357,28 +1357,28 @@ sub
bless($self,$class);
}
-#line 71 "./pidl/expr.yp"
+#line 121 "./../pidl/expr.yp"
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;
@@ -1386,13 +1386,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($$)
@@ -1429,14 +1429,16 @@ 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);
}
1;