in reply to Re^2: Parsing and converting Fortran expression
in thread Parsing and converting Fortran expression [solved]

Thanks, this is almost perfect!

With a few modifications I could use it right away. (Those modifications were required mostly because my original specs were not complete enough. I've added this to handle all logical operators I needed:

sub op { { '.and.' => '&&', '.or.' => '||', '.eq.' => '==', '.ne.' => '!=', '.eqv.' => '==', '.neqv.' => '!=', '.lt.' => '<', '.gt.' => '>', '.le.' => '<=', '.ge.' => '>=', }->{$_[0]} // $_[0]; } # left associative => term (.and. term)* sub expr { my $left = term(); $left = "(($left) " . op($1) . " (" . term() . '))' while /\G\s* (\. +\w+\.) /gcx; return $left; }

)

(I'm the OP, I just can't log in from here, but I'll upvote when I get the chance)

Thanks again!