Questions tagged [ml-yacc]

ML-yacc is a parser generator for for Standard ML.

ML-yacc is a parser generator for Standard ML (). It is a variant of yacc, and uses a similar syntax; it produces an ML program instead of a C program.

It normally would use to build a lexer for use with an ML parser.

Resources:

See Also:

9 questions
1
vote
2 answers

ML-Yacc Tiger Parser Reduce/Reduce error

I am going through the Ch3 programming exercise of generating a Tiger Parser in Appel's "Modern Compiler Implementation in ML" book. My tiger.grm file is here. The error I am trying to diagnose is a reduce-reduce conflict arising from rules for…
aspen100
  • 965
  • 11
  • 22
1
vote
2 answers

Removing reduce/reduce conflicts

I've created a compiler for a language which has the following grammer, as defined by ML-Yacc (Starting symbol is "program" which is defined at the bottom): %nonassoc FUN VAR ASSIGN PLUSASSIGN MINUSASSIGN TIMESASSIGN DIVIDEASSIGN %right …
0
votes
1 answer

How can I resolve this shift-reduce conflict?

I'm following Appel's book Modern Compiler Implementation in ML and am trying to write a grammar for Tiger. Here's my first attempt: %% %term EOF | ID of string | INT of int | STRING of string | COMMA | COLON | SEMICOLON | LPAREN |…
Bridge
  • 105
  • 1
  • 8
0
votes
1 answer

Referencing Multiple Non-Terminals in Production with Same Name in Yacc

Let's assume I have the production: Expression // These are my semantic actions : Expression PLUS_TOKEN Expression ( create_node(Expression, Expression) ) | SimpleExpression ( SimpleExpression ) (*…
0
votes
2 answers

Conflicts in Parser for Propositional logic with IF-THEN-ELSE ternary operator

I want to implement the Parser for proposition logic which has the following operators in decreasing order of precedence: NOT p p AND q p OR q IF p THEN q p IFF q IF p THEN q ELSE r The main issue is with the IF-THEN-ELSE operator. Without it, I…
Deepak Saini
  • 2,810
  • 1
  • 19
  • 26
0
votes
1 answer

ML-Yacc Tiger Parser not properly parsing lvalue

I'm working on the parser component of my Tiger compiler in SML using ML-Yacc. I cannot find any glaring problems with my grammar file (I've used priority rules to resolve all shift-reduce conflicts) but it seems to never reduce using the second and…
MattDs17
  • 401
  • 1
  • 4
  • 20
0
votes
1 answer

ML-Yacc error concerning 12 shift/reduce conflicts involving EXP -> EXP BINOP EXP

This is the error: 12 shift/reduce conflicts error: state 34: shift/reduce conflict (shift OR, reduce by rule 11) error: state 34: shift/reduce conflict (shift AND, reduce by rule 11) error: state 34: shift/reduce conflict (shift GE, reduce…
Joe
  • 1,076
  • 3
  • 10
  • 17
0
votes
1 answer

Ml-yacc parsing issues.. dealing with type "unit"

First of all, this is a homework. I have to make a program which can parse the language described here: http://www.cs.princeton.edu/courses/archive/spring12/cos320/resources/fun_language_definition.html This is an example of the Fun language: fun…
Madrugada
  • 1,261
  • 8
  • 24
  • 44
-1
votes
1 answer

Language used in bison/yacc files

I wonder what is the language used in the curly braces of the rule section in yacc/bison files like the following and if there is any good reference about it. stmts : stmt { $$ = new NBlock(); $$->statements.push_back($1); } | stmts stmt {…
Rational Rose
  • 73
  • 1
  • 10