Re: Looking for Perl Grammar



Joe Smith wrote:
Khamis Abuelkomboz wrote:

I'm writing a Perl parser and I'm looking for a pure perl grammar.


You won't find it.

My favorite example is this:

#!/usr/bin/perl -l
print time / 2 ; #/;  die  'This die() is not executed';
print cos  / 2 ; #/;  warn 'But this warn() is!';

To resolve the ambiguity of / as numerator/denominator versus m//
requires knowledge of which functions require arguments and which
do not.  And if the program has 'use Module;', to determine which
user-defined functions take arguments and which do not requires
actually parsing the Module.  You can't do that with pure grammar.
    -Joe

you got the problem, there is no clear way, when to figure out, using "/", if it is a numeric operator or a string match clause.
However I'm really not writing grammar for perl, but use similar way, how perl parse itself. my parsing gools is reporting functions, classes and variables plus cross-referencing.
I have resolved the most problems I have, however a 99% rate for "correct" interpreting the perl files is enough for me.


However I still find clauses like

if ( s{foo}{bar} ) ...
if ( s[foo][var] ) ...
if ( s<foo><bar> ) ...

I still don't figure out what could be used as "brackets" for the s|tr|m commands???? So I'm looking as example for grammar descriping how the (s, tr, qq) could be built, something like

S: s OP1 expr OP2 expr OP3
OP1: '/' | '{' | '[' | ':' | ...
OP2: '/' | '}{' | '][' | ...
OP3: '/' | '}' | ']' | ':' | ...

I'm still guissing :-)

regards
khamis
--
Try Code-Navigator on http://www.codenav.com
a source code navigating, analysis and developing tool.
It supports following languages:
    * C/C++
    * Java
    * .NET (including CSharp, VB.Net and other .NET components)
    * Classic Visual Basic
    * PHP, HTML, XML, ASP, CSS
    * Tcl/Tk,
    * Perl
    * Python
    * SQL,
    * m4 Preprocessor
    * Cobol
.



Relevant Pages

  • Re: send text from word doc to .txt file
    ... i want to perform a spell and grammar check in a minority language on the ... text in ms word.the checker is in perl and is used at the command line - dos ... formatting - extra white spaces. ... >> Is there a way to select all of the text on an open word document ...
    (microsoft.public.word.vba.general)
  • Re: send text from word doc to .txt file
    ... i want to perform a spell and grammar check in a minority language on the ... text in ms word.the checker is in perl and is used at the command line - dos ... formatting - extra white spaces. ... >> Is there a way to select all of the text on an open word document ...
    (microsoft.public.word.vba.general)
  • Re: Looking for Perl Grammar
    ... And if the program has 'use Module;', to determine which user-defined functions take arguments and which do not requires actually parsing the Module. ... You can't do that with pure grammar. ... However I'm really not writing grammar for perl, but use similar way, how perl parse itself. ... my parsing gools is reporting functions, ...
    (comp.lang.perl.misc)
  • Re: perl 5 grammar
    ... Mike> I maintain the syntax highlighter for code.google.com and perl support ... Mike> is rather lacking. ... Mike> simple lexical grammar for perl 5 that will allow me to at least ... even likely in someone's production code. ...
    (comp.lang.perl.misc)
  • Re: Looking for Perl Grammar
    ... > I'm writing a Perl parser and I'm looking for a pure perl grammar. ... > documentation from perl is not a pure grammar, ...
    (comp.lang.perl.misc)