6

Are there known and mature parser generators that both support php and javascript?

The aim is to have a single grammar definition and parsers in php and javascript that are generated from it.

Are there any?

0x6A75616E
  • 4,696
  • 2
  • 33
  • 57
zerkms
  • 249,484
  • 69
  • 436
  • 539
  • You mean, one parser for both o0 – samayo May 07 '13 at 03:29
  • @php NoOb: I'm not sure I understand what you mean. Here are something for you to read: http://en.wikipedia.org/wiki/Parsing_expression_grammar http://en.wikipedia.org/wiki/Ebnf – zerkms May 07 '13 at 03:31
  • 2
    If you're looking for a yacc/lex type of deal, someone actually asked that earlier today... – Dagg Nabbit May 07 '13 at 03:32
  • 1
    I'm guessing he wants to write a single grammar definition and get a working parser generated for both languages. – xaxxon May 07 '13 at 03:32
  • @Dagg Nabbit: yep, it would be nice. PS: there is a link in the Related http://stackoverflow.com/questions/79584/are-there-any-parsing-expression-grammar-peg-libraries-for-javascript-or-php?rq=1 but `php-peg` unfortunately is died (and with weird not fixed bugs) – zerkms May 07 '13 at 03:34
  • 1
    @zerkms unfortunately, questions about lexers don't seem very well-received here, but you're probably got a big enough number next to your name to counteract those negative effects ;) – Dagg Nabbit May 07 '13 at 03:36
  • @Dagg Nabbit Why not? :( Lexers are awesome! :) – Patashu May 07 '13 at 04:11

1 Answers1

1

Yes, there is. Have look at ANTLR. Note: this is for ANTLR3. There's already a new version (ANTLR4) but it supports only Java and C# at the time being.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181