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
0
votes
1 answer

Yacc recursion method for echoing a list?

I am struggling to understand yacc recursion. So I created a minimal language that I want to simply echo a list of number given to it. I am using JISON. Here is the JISON: /* description: Parses end executes mathematical expressions. */ /*…
user2302244
  • 843
  • 2
  • 11
  • 27
0
votes
0 answers

Jison Actions Checking Type?

Checking to see if I'm doing this right. I think I have a fairly firm grasp on BNF grammars, but don't quite get how the actions are supposed to work. The WORD token below is a string. The tag list should be an array of tags. The other rules…
Justin Thomas
  • 5,680
  • 3
  • 38
  • 63
0
votes
1 answer

How can I pass additional input to `parse` in jison?

I want to parse a string, but this string may contain references to variables that are resolved at run time. Ideally, I'd like to pass in a hash of these variables and their values as the second argument to the parse function. Currently, I'm running…
Soumya
  • 13,677
  • 6
  • 34
  • 49
0
votes
1 answer

Parsing a string using Jison/Bison

I'm trying to learn how to use Jison (a Javascript parser generator that uses Bison syntax). I have some code that looks like this: a: "{{index()}}" b: "{{blah(2, 'aba')}}" I'm trying to create a parser that will return index() if passed string a,…
Isaac Dontje Lindell
  • 3,246
  • 6
  • 24
  • 35
0
votes
1 answer

Jison / Flex: Trying to capture anything (.*) between two tokens but having problems

I'm currently working on a small little dsl, not unlike rabl. I'm struggling with the implementation of one of my rules. Before we get to the problem, I'll explain a bit about my syntax/grammar. In my little language you can define properties,…
Jason L.
  • 2,464
  • 1
  • 23
  • 41
0
votes
1 answer

How to handle multiple rules for one token with PLY

I'm working with a jison file and converting it to a parser generator using the lex module from python PLY. I've noticed that in this jison file, certain tokens have multiple rules associated with them. For example, for the token CONTENT, the file…
Adam
  • 12,236
  • 9
  • 39
  • 44
0
votes
1 answer

Jison/Bison Get line number of a token in a grammar

I am wondering how shall I get the line number of a token inside a grammar. Suppose I have the following grammar: S : expr MINUS expr { $$ = $1 -$3; } ; How to get the line number for MINUS token? I am not using the lexer inside jison but rather…
Ra1nWarden
  • 1,170
  • 4
  • 21
  • 37
0
votes
1 answer

Parse user name and strings

I am trying to parse the following string input using Lex and Yacc with no success. "@user;some random text; @another user; some other random text" I am using the following grammar: /* Lambda calculus grammar by Zach Carter */ %lex %% \s*\n\s* …
GETah
  • 20,922
  • 7
  • 61
  • 103
0
votes
2 answers

How to solve this S/R conflict

Here's a simplification of my working EBNF grammar: %token NEWLINE BLOCK_MARK A %start file file: block+ NEWLINE*; block: BLOCK_MARK line; line: A+; Both \n and EOF spit out NEWLINE as a token (so that a single ending NEWLINE isn't required before…
kaoD
  • 1,534
  • 14
  • 25
0
votes
1 answer

Issue with a Jison Grammar, Strange error from generate dparser

I am writing a simple Jison grammar in order to get some experience before starting a more complex project. I tried a simple grammar which is a comma separated list of numeric ranges, with ranges where the beginning and ending values were the same…
rgvtim
  • 3
  • 1
0
votes
1 answer

Jison parser may not be tokenizing correctly. (I think)

It's been a while since I've done any work with Flex or Bison, going back to college. However, I've been trying to roll my own light-BBCode parser using Jison for fun as a weekend endeavor. My problem involves an odd issue in which I'm told the…
Matt
  • 515
  • 3
  • 16
0
votes
0 answers

"Combine" logical expression and return the subexpressions

I need to write an algorithm that takes a logical expression as input, combines its operators and returns the subexpressions. Some examples of what I need: foo -> ["foo"] foo bar -> ["foo bar"] foo bar OR baz -> ["foo bar", "baz"] foo bar (baz OR…
0
votes
2 answers

Where is this shift/reduce conflict coming from in Bison?

I am trying to get the hang of parsing by defining a very simple language in Jison (a javascript parser). It accepts the same / very similar syntax to bison. Here is my grammar: %token INT TRUE FALSE WHILE DO IF THEN ELSE LOCATION ASSIGN EOF…
user2269972
  • 31
  • 1
  • 2
0
votes
2 answers

Dynamic parser - read tokens from a separate file

Let's say I want to parse my new language that looks like this: main.mylang import "tags.mylang" cat dog bacon And there's another file tags.mylang that looks like this: cat "meow" dog "woof" bacon "sizzle" Running main.mylang would output meow…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
0
votes
1 answer

Is this grammar ambiguous?

I'm trying to define a language using Jison with very little punctuation for delimitation - like CoffeeScript but without the indentation. This is sort of what I want to achieve: # Definition object1, object2 property1 = value1, property2 =…
Daniel Buckmaster
  • 7,108
  • 6
  • 39
  • 57
1 2 3
9
10