Is there any formal PHP syntax definition? - PHP
This is a discussion on Is there any formal PHP syntax definition? - PHP ; I need to write a few tools that do PHP syntax parsing and the
tutorial like documentation for example
"http://www.php.net/manual/en/language.oop5.php" is really not a good
reference.
Isn't there some more formal language definition text....
-
Is there any formal PHP syntax definition?
I need to write a few tools that do PHP syntax parsing and the
tutorial like documentation for example
"http://www.php.net/manual/en/language.oop5.php" is really not a good
reference.
Isn't there some more formal language definition text.
-
Re: Is there any formal PHP syntax definition?
On Mar 12, 2:19 pm, llothar <llot...@web.de> wrote:
> I need to write a few tools that do PHP syntax parsing and the
> tutorial like documentation for example
> "http://www.php.net/manual/en/language.oop5.php" is really not a good
> reference.
>
> Isn't there some more formal language definition text.
How about the book Programming PHP? or maybe the PHP source code?
I myself would start with whatever reference and start right from
there, there's nothing like experience.
Though if you mix in HTML (which most programmers usually do) it gets
even more complicated.
-
Re: Is there any formal PHP syntax definition?
On Mar 12, 2:19 pm, llothar <llot...@web.de> wrote:
>
> I need to write a few tools that do PHP syntax parsing
What's wrong with using PHP source code for that?
Cheers,
NC
-
Re: Is there any formal PHP syntax definition?
>
> How about the book Programming PHP? or maybe the PHP source code?
>
> I myself would start with whatever reference and start right from
> there, there's nothing like experience.
>
> Though if you mix in HTML (which most programmers usually do) it gets
> even more complicated.
Sorry i really hate this. I have the same problem with ruby where the
guys
are also not willing to do a formal language definition.
Fact is that the C-like code that PHP is using sucks and learning this
is just
an order of magnitude slower then just looking at a good BNF language
definition.
It is also more precisely and way safer to be sure you haven't
overseen anything.
I know about programming. You don't need to tell me that.
-
Re: Is there any formal PHP syntax definition?
llothar <llothar@web.de> wrote:
> I need to write a few tools that do PHP syntax parsing and the
> tutorial like documentation for example
> "http://www.php.net/manual/en/language.oop5.php" is really not a good
> reference.
>
> Isn't there some more formal language definition text.
The formal systax of PHP is available in the source code package, see files
Zend/zend_language_scanner.l (Lex scanner)
Zend/zend_language_parser.y (Yacc parser)
It is starting from here that the PHP sources generate at compile-time its
scanner and its parser, so you may want to do the same for your program. I have
also translated the BNF Yacc configuration file into a more readable EBNF
version that may be useful for human reference, it is available here (select
the "PHP" example):
http://www.icosaedro.it/bnf_chk/bnf_chk-on-line.html
Best regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it
-
Re: Is there any formal PHP syntax definition?
> > Sorry i really hate this. I have the same problem with ruby where the
> > guys
> > are also not willing to do a formal language definition.
>
> The php.net site is pretty good.
Sorry it just reflects the total inability of the PHP/Zend team to do
any consistent
definition/programming. It sucks. Yes you can find information but you
have to read
the _USER_ supplied comments.
I don't want an ANSI/ECMA/ISO spec but something like python would be
nice.
> > It is also more precisely and way safer to be sure you haven't
> > overseen anything.
>
> I prefer the C coding style to other languages.
Zend engine is not C style. It's a psyeudo C language implemented with
C macros.
This makes it worse. I like C, i'm programming in C for more then 18
years.
> > I know about programming. You don't need to tell me that.
>
> So, don't like PHP?
Doesn't matter. I'm writting a PHP IDE so i need some precise
specification.
And it's always better to something in a specification document
because only
then you can tell if it is a bug or not.
> There are a gazillion other languages you can use instead.
Why do such idiots like you never die. The question was not about
another language
but about a weakness of the current language.
-
Re: Is there any formal PHP syntax definition?
>> Sorry i really hate this. I have the same problem with ruby where the
>> guys
>> are also not willing to do a formal language definition.
>>
>
> The php.net site is pretty good.
>
>> Fact is that the C-like code that PHP is using sucks and learning this
>> is just
>> an order of magnitude slower then just looking at a good BNF language
>> definition.
>> It is also more precisely and way safer to be sure you haven't
>> overseen anything.
>>
>
> I prefer the C coding style to other languages.
And I prefer the "basic-style" alternative syntax.
To the original poster: You know what? You can use them both! PHP itself
couldn't care less! I encounter more and more people (also in the Python
newsgroup) who ask for syntax schemes but do not want to create one
themselves.
Too bad, because that IS the syntax scheme used in the languages: just
add features as needed and use your aesthetic feelings rather than some
rigid scheme to see if it fits in. I think a strict and abstract syntax
scheme is not a feature the PHP developers had a need to.
Such a scheme can even be a disadvantage. If you have a fixed set of
keywords, you might stick to them and reuse them in all sorts of
incompatible places (like the "final" keyword in Java), or even give a
special meaning to the absence of a keyword (again, Java: "friend"
visibility). Schemes are not a guarantee of quality, and absence of such
a scheme is not necessarily a bad thing.
Best regards.
-
Re: Is there any formal PHP syntax definition?
llothar wrote:
>> How about the book Programming PHP? or maybe the PHP source code?
>>
>> I myself would start with whatever reference and start right from
>> there, there's nothing like experience.
>>
>> Though if you mix in HTML (which most programmers usually do) it gets
>> even more complicated.
>
> Sorry i really hate this. I have the same problem with ruby where the
> guys
> are also not willing to do a formal language definition.
>
The php.net site is pretty good.
> Fact is that the C-like code that PHP is using sucks and learning this
> is just
> an order of magnitude slower then just looking at a good BNF language
> definition.
> It is also more precisely and way safer to be sure you haven't
> overseen anything.
>
I prefer the C coding style to other languages.
>
> I know about programming. You don't need to tell me that.
>
>
So, don't like PHP? There are a gazillion other languages you can use
instead.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
-
Re: Is there any formal PHP syntax definition?
llothar wrote:
>>> Sorry i really hate this. I have the same problem with ruby where the
>>> guys
>>> are also not willing to do a formal language definition.
>> The php.net site is pretty good.
>
> Sorry it just reflects the total inability of the PHP/Zend team to do
> any consistent
> definition/programming. It sucks. Yes you can find information but you
> have to read
> the _USER_ supplied comments.
>
So, the language is evolving. Every language has done it.
> I don't want an ANSI/ECMA/ISO spec but something like python would be
> nice.
>
I'm sure if you're willing to pay them enough, they will develop one for
you. But the rest of us have no need.
>>> It is also more precisely and way safer to be sure you haven't
>>> overseen anything.
>> I prefer the C coding style to other languages.
>
> Zend engine is not C style. It's a psyeudo C language implemented with
> C macros.
> This makes it worse. I like C, i'm programming in C for more then 18
> years.
>
It has its roots in C, and is pretty close to C. And I've been doing C
about 6 years longer than you.
>>> I know about programming. You don't need to tell me that.
>> So, don't like PHP?
>
> Doesn't matter. I'm writting a PHP IDE so i need some precise
> specification.
> And it's always better to something in a specification document
> because only
> then you can tell if it is a bug or not.
>
So, pay Zend to create it for you. It's simple. They might even have
an internal specification you can purchase. But most of us don't need it.
>> There are a gazillion other languages you can use instead.
>
> Why do such idiots like you never die. The question was not about
> another language
> but about a weakness of the current language.
>
Not at all. I'm just tired of people like you who do nothing but bitch.
You don't like it? Go someplace else. Or design your own language.
And this isn't about a weakness in the language. It's just plain bitching.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
-
Re: Is there any formal PHP syntax definition?
> To the original poster: You know what? You can use them both! PHP itself
> couldn't care less! I encounter more and more people (also in the Python
> newsgroup) who ask for syntax schemes but do not want to create one
> themselves.
But Python has a syntax definition and even a language (semantic)
definition.
Thats why it is much easier to have a Jpython or IronPython out there
and
a lot of other programming tools. Programmers of tools just need
this.
> Too bad, because that IS the syntax scheme used in the languages: just
> add features as needed and use your aesthetic feelings rather than some
> rigid scheme to see if it fits in.
This is a total offtopic answer. I was not talking about the process
of
improving the language but the specification after you found a
solution that
matches your "aesthetic feelings" (which really hurts me to type when
i see
and work with this IMHO absolute unaesthetic php constructs).
> I think a strict and abstract syntax
> scheme is not a feature the PHP developers had a need to.
They don't have it. But once a language has a large user base you need
it
for all 3rd party vendors who work with the languages. I know PHP is
considered a toy language and most problems came from such an
attitude.
> Such a scheme can even be a disadvantage. If you have a fixed set of
> keywords, you might stick to them and reuse them in all sorts of
> incompatible places (like the "final" keyword in Java), or even give a
> special meaning to the absence of a keyword (again, Java: "friend"
> visibility). Schemes are not a guarantee of quality, and absence of such
> a scheme is not necessarily a bad thing.
No but you can for example see what changed.
Sorry i better stop here. It's a pain in the ass to talk to somebody
who
is just a user of a language and not a language/tool producer itself.