Re: Looking for Perl Grammar
- From: Khamis Abuelkomboz <khamis@xxxxxxxxxxxx>
- Date: Sat, 30 Apr 2005 20:18:08 +0200
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 .
- Follow-Ups:
- Re: Looking for Perl Grammar
- From: Fabian Pilkowski
- Re: Looking for Perl Grammar
- From: John W. Krahn
- Re: Looking for Perl Grammar
- References:
- Looking for Perl Grammar
- From: Khamis Abuelkomboz
- Re: Looking for Perl Grammar
- From: Joe Smith
- Looking for Perl Grammar
- Prev by Date: Re: a regex question ..
- Next by Date: Re: Looking for Perl Grammar
- Previous by thread: Re: Looking for Perl Grammar
- Next by thread: Re: Looking for Perl Grammar
- Index(es):
Relevant Pages
|