PHP Language Defenition

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Martin Lundberg - Sweden
Avatar
Hello again! =)

I've been working on a XML Language Defenition for PHP and I've been thinking... Every Php file/content must be between <?(php) and ?> so should I set a scope on the DefaultState or should I let the DefaultState have a ChildState which is PHPState and give that state the start- and endscope of <?(php) and ?>.

Thanks in advance!

Martin Lundberg
Student, Sweden

Comments (5)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
PHP really is similar to an ASP block (<% ... %> ). You should not define the <?php or ?> in your PHP def. Instead just put the language definition in it.

Then make a higher-level HTML definition that does a language transition into the PHP one when those patterns are found. It's similar to our HTML/ASP sample.


Actipro Software Support

Posted 14 years ago by Martin Lundberg - Sweden
Avatar
Hello and once again, thanks!

But I was wondering, what about files where you only have php code? When making classes for example you often have them in seperate files where no xhtml is present?

Martin Lundberg
Student, Sweden

Posted 14 years ago by AdrianRitchie - Guernsey, UK
Avatar
because you can never be certain whether or not a PHP file will contain HTML you should (for completeness) use the ASP approach described.

If you're worried about overhead with loading up a full XHTML definition file aswell as the PHP one, you could create a light weight version for PHP files you're pretty sure wont have HTML in.
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Adrian is exactly right. You should create a base PHP language definition for just the PHP language and a small stub parent language definition if you don't plan on having complicated HTML encapsulating it.


Actipro Software Support

Posted 14 years ago by Martin Lundberg - Sweden
Avatar
Okey Thanks! =)

So you also add whitespace and lineterminators to tokens, I'm just wondering why?

I am totally new to this so if it's obvios for the other people here I'm sorry.

What would you later use a whitespace tokens and lineterminatortokens for?

[ 12-07-2004: Message edited by: Martin Lundberg ]

Martin Lundberg
Student, Sweden

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.