Questions tagged [jison]

A parser generator for JavaScript.

Jison produces a parser from a context-free grammar.

Highlights:

  • Close compatibility with bison, lex and yacc grammars for lexer and parser definitions.
  • As the parsers it generates are plain JavaScript, they can be embedded in a web page executing inside the browser (similarly to OmetaJS, in that regard).

Resources:

Note:
There is the original Jison (AKA Vanilla Jison) that has not been updated lately and the GitHub GerHobbelt fork that is actively maintained.

139 questions
2
votes
1 answer

Jison: produce AST node with multiple children for AND and OR

I am working on a simple SQL to Mongo query criteria generation in JavaScript. I am using Jison to parse the SQL's where clause. The following grammar returns an AST in form of binary tree where ORs and ANDs are nested. What I want is to obtain an…
2
votes
2 answers

Jison recursion

I'm trying to get a hang of Jison. I'm having a bit of a trouble though. The following parser always returns [], no matter what you give it. %lex %% "data"\s* return 'DATA' [A-Za-z][A-Za-z0-9_]* return 'IDENTIFIER' [0-9]+("."[0-9]+)?\b …
seequ
  • 456
  • 2
  • 13
2
votes
1 answer

jison grammar definition leads to wrong token recognition

I recently found the project jison and modified the calculator example from its website. (http://zaach.github.io/jison/demos/calc/) /* lexical grammar */ %lex %% "a" return 'TOKEN1' "b" return 'TOKEN2' <> …
flexxx
  • 23
  • 2
2
votes
2 answers

Jison rule precedence

I'm trying to create a grammar for a programming language in Jison, and have run into a problem with calls. Functions in my language is invoked with the following syntax: functionName arg1 arg2 arg3 In order to do arguments that aren't just simple…
Alxandr
  • 12,345
  • 10
  • 59
  • 95
2
votes
0 answers

How to create user defined function in JISON (Parser Generator)?

I have already finish writing the abstract syntax tree calculator with assignment capability But I have no idea how the UDF can be done. I have planned to add a new function called "funcasgn" And somewhat parse through the defined-function. But the…
2
votes
2 answers

Jison ignores one of my rules

I'm trying to use Jison. Here's my grammar: var grammar = { lex:{ rules:[ ["\\s+", ""], ["then", "return 'newline';"], ["goto", "return 'goto';"], ["http[^\\s]*", "return…
Micah
  • 10,295
  • 13
  • 66
  • 95
2
votes
1 answer

Understanding Bison/Jison

I am looking to create a JavaScript parser for an existing language, that currently has clumsy "hand-made" C# and Java parsers. I want to use Jison, and have been trying to learn the basics of Bison as well. A question I'm not sure how to answer is…
Mosho
  • 7,099
  • 3
  • 34
  • 51
2
votes
3 answers

Code substitution (a la #define). Lexer? or Parser?

tl;dr: How do you emulate the equivalent of C's #define with jison without doing a pre-processing step? I am working on a relatively simple grammar with a feature to assign an identifier to a chunk of code that can then be re-used later for brevity.…
abelnation
  • 121
  • 2
  • 6
2
votes
1 answer

JISON: why in regexp used "." instead of \.?

From example on http://zaach.github.io/jison/docs/#specifying-a-language [0-9]+("."[0-9]+)?\b return 'NUMBER'; why in this regexp used "." instead of \. ?
redexp
  • 4,765
  • 7
  • 25
  • 37
2
votes
1 answer

Jison: Reduce Conflict where actually no conflict is

I'm trying to generate a small JavaScript parser which also includes typed variables for a small project. Luckily, jison already provides a jscore.js which I just adjusted to fit my needs. After adding types I ran into a reduce conflict. I minimized…
Benjamin Schulte
  • 863
  • 1
  • 6
  • 16
2
votes
1 answer

SyntaxError in Jison parser

I'm trying to write a parser using Jison that'll parse the output of the javap tool. Here's the contents of my .jison file: %lex %x classfile %% "Classfile" { this.begin("classfile"); } \s+ { /* ignore…
cdmckay
  • 31,832
  • 25
  • 83
  • 114
1
vote
2 answers

Implicit precedence

I'm reading book — "Flex and Bison" to understand how parser generators work and there is example: calclist: /* nothing */ | calclist exp EOL { printf("= %d\n", $1); } ; exp: factor | exp ADD factor { $$ = $1 + $3; } | exp…
Protoman
  • 108
  • 1
  • 5
1
vote
0 answers

Syntax error in JISON with simple grammar

I'm trying to implement a very simple parser, but I'm having a problem. I have the following grammar: %lex %options flex case-insensitive CaracterEscape [\'\"\\bfnrtv] Escape \\{CaracterEscape} CaracterCadena …
1
vote
1 answer

Error while tokenizing Bangla Number(Digits) as Number token using RegEx

I'm new to Jison and I want to tokenize Bangla Digits ০-৯ as numbers. I've tried the regex below but it's not working with it: Regular Expression: (^[\u09E6-\u09EF])+("."[\u09E6-\u09EF])\b On testing ৭+১ It showing expected... 'NUMBER' GOT 'Invalid'…
1
vote
0 answers

Parsing .aspx and .ascx files to use in a VSCode Prettier Plugin

I've searched with no luck to find a parser for .aspx and .ascx files that could be used to create a VSCode formatting plugin using the Prettier extension. I've resorted to creating my own parser from scratch, which I have mostly done successfully…
Brandon B
  • 23
  • 2
1 2
3
9 10