AlexanderJohannesen
AlexanderJohannesen

Reputation: 2028

PHP text parsing and / or make your own language?

Been Googling around without finding much at all, so does anyone know of a class or library that helps you parse any sort of language, like a Domain Specific Language (I'm creating one, so I'm flexible in what the syntax and format can be) into either PHP code or some helpful struct or a class hiearchy or ... ? Anything goes at this point. :)

I want to experiment with parsing text files into tokens, building up a small grammar and syntax library to express things like Business Natural Languages.

Upvotes: 3

Views: 1512

Answers (1)

maetl
maetl

Reputation: 888

If you're comfortable with BNF style input syntax, you should look at:

http://pear.php.net/PHP_ParserGenerator

or

http://pear.php.net/PHP_LexerGenerator

The PHP code they generate is a little disturbing, but it works, and is a good head-start for some parser tasks.

Upvotes: 2

Related Questions