Is there a flex - bison parser for javascript? [closed]
Asked Answered
T

3

9

Is there a parser available in the open ? Else, i'm planning to write one using the grammar rules in http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf

Thanks.

Tolu answered 1/8, 2012 at 8:8 Comment(3)
Interesting ! Why isnt there one already ? Perhaps there is a better javascript parser out there ? any gnu tool ??Tolu
@Tolu Did you ever find the grammar files for flex/bison or similar?Tithable
Did you think about parser generator, like flex and bison for javascript OR Grammar for javascript itself?Pudding
E
12

I think you can try Jison.

Jison takes a context-free grammar as input and outputs a JavaScript file capable of parsing the language described by that grammar. You can then use the generated script to parse inputs and accept, reject, or perform actions based on the input. If you’re familiar with Bison or Yacc, or other clones, you’re almost ready to roll.

https://gerhobbelt.github.io/jison/docs/

Elicia answered 31/1, 2013 at 10:17 Comment(0)
F
0

Or you could try Jacob, a lexer and parser generator for JavaScript:

http://canna71.github.io/Jacob/

Forename answered 23/9, 2014 at 7:18 Comment(0)
B
-3

There's plenty of programs that parse JS out there, mainly the many linter programs. JSLINT/JSHINT, etc. Crockford has written a bit about the parser he makes use of in JSLINT http://javascript.crockford.com/tdop/tdop.html

I know it's not bison/grammar generated, but is that a strict requirement?

Barvick answered 1/8, 2012 at 10:46 Comment(2)
yes, i need it to be grammar dependent - to be specified in terms of grammar -> action, so i can define my own actions..Tolu
For what purpose do you wish to define actions, are you writing an interpreter, some kinda of analysis tool?Barvick

© 2022 - 2024 — McMap. All rights reserved.