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
1
vote
2 answers

Making Arrays in Jison

I'm trying to add support for arrays in my programming language and am having trouble Array : '[' Expr ("," Expr)* ']' {{ $$ = ['ArrayList', $1]; }} | '[' Expr ']' {{ $$ = ['Array', $2]; }} | '[' ']' {{ $$ = ['Empty']; }} …
1
vote
1 answer

Parsing newline in Jison

Hi I am a newbie for Jison and was trying to learn it. I try the online jison parser calculator code on http://techtonik.github.io/jison/try/. It is working fine for the expression 5*PI^2. But when I added a new expression on a newline, the…
Vijay
  • 439
  • 3
  • 15
1
vote
0 answers

Jison: get the token name

How do I get access to the token name "NUMBER"? | NUMBER {$$ = /* "NUMBER" */;} I couldn't find anything useful by console.log(yy).
ikaruss
  • 491
  • 4
  • 13
1
vote
0 answers

Jison: Getting parsed token instead of what is defined in Grammar

I am attempting to generate a parser related to recipe ingredients. I am noticing that the order the parser handles tokens seems to follow the token's line-item order in the jison file, vs. whats defined in the EBNF grammar. For example, parsing 6…
aphexddb
  • 76
  • 1
  • 5
1
vote
2 answers

Empty blocks and empty objects grammar conflict warnings

I'm trying to implement a parser in Jison. The parser has support for both JSON objects: { a: 1 } and blocks: if (true) { statement(); }. My grammar looks like: block: : '{' '}' | '{' statementList '}' ; objectExpression: : '{' '}' | '{'…
Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288
1
vote
3 answers

Is there an easy way to make Jison calculator parser return symbolic results?

Jison parsers return the calculated result: calculator.parse("2^3"); // returns 8 calculator.parse("x^2"); // gives a parse err I would like that it return the symbolic expression: calculator.parse("x^2"); // should return //…
marco alves
  • 1,707
  • 2
  • 18
  • 28
1
vote
1 answer

How do I define a String in JISON

I am just getting into writing a DSL and would like to use JISON (http://zaach.github.io/jison). I am trying to learn the grammar syntax and am running into a problem with specifying a string of characters in double quotes. What I would think would…
kalisjoshua
  • 2,306
  • 2
  • 26
  • 37
1
vote
1 answer

Match newlines only under specific conditions

I am writing parser of language similar to javascript with its semicolon insertion ex: var x = 1 + 2; x; and var x = 1 + 2 x and even var x = 1 + 2 x are the same. For now my lexer matches newline (\n) only when it occurs after token different…
Krzysztof Kaczor
  • 5,408
  • 7
  • 39
  • 47
1
vote
1 answer

Convert jison object back to string

So I have created a .jison file for a search query language that is basically a subset of the SQL where statement. That file can be viewed here: https://gist.github.com/ryanzec/7d1c8100d1b5f03c0a17 Now it works as I expect it to when converting a…
ryanzec
  • 27,284
  • 38
  • 112
  • 169
1
vote
2 answers

“IF ELSE” statement inside basic calculator

I’m trying to implement my own calculator with “IF ELSE” statements. Here is the basic calculator example: /* description: Parses end executes mathematical expressions. */ /* lexical grammar */ %lex %% \s+ /* skip whitespace…
Paul
  • 103
  • 13
0
votes
1 answer

How can I get youtubeVideo Title from URL for android studio?

I want to get the youtube video title from a url so I found this code below (IOUtils) is depreciated any other way to do this public class SimpleYouTubeHelper { public static String getTitleQuietly(String youtubeUrl) { try { if…
0
votes
2 answers

Remove ambiguity in grammar for expression casting

I'm working on a small translator in JISON, but I've run into a problem when trying to implement the cast of expressions, since it generates an ambiguity in the grammar when trying to add the production of cast. I need to add the productions to the…
0
votes
1 answer

How to make a chained comparison in Jison (or Bison)

I'm working on a expression parser made in Jison, which supports basic things like arithmetics, comparisons etc. I want to allow chained comparisons like 1 < a < 10 and x == y != z. I've already implemented the logic needed to compare multiple…
m93a
  • 8,866
  • 9
  • 40
  • 58
0
votes
0 answers

How to work with tokenized Bangla digits in Jison?

I am newbie at jison, using the following grammer with jison: /* lexical grammar */ %lex %% \s+ /* skip whitespace */ [০-৯]+(?:\.[০-৯]+)? return 'NUMBER' "*" return '*' "/" return '/' "-" …
0
votes
1 answer

how to tokenize bangla digits as nunbers and work with them?

Salam❤️ I am beginner at Jison. Learning small things day by day. How I could work with Bangla Numbers with Jison? I meant, How can I work with jison and use Bangla Digits as NUMBER token and work with them (RESULT NUMBER MUST BE IN BANGLA) I used…