Questions tagged [ocamlyacc]

ocamlyacc is a Parser generator for OCaml (mostly deprecated by Menhir)

ocamlyacc is a Parser generator for OCaml, derived from yacc.

Used to build the OCaml compiler, it is included in the official distribution. However, it is not supported anymore, and the official policy is that OCaml users should use Menhir[2] instead. Indeed, Menhir is mostly backward compatible (it can read ocamlyacc source files), but improves over ocamlyacc in many directions (grammars can be combined, symbols can be named, etc.)

[2] http://gallium.inria.fr/~fpottier/menhir/

See also:

84 questions
0
votes
2 answers

Parse a list of subroutines

I have written parser_sub.mly and lexer_sub.mll which can parse a subroutine. A subroutine is a block of statement englobed by Sub and End Sub. Actually, the raw file I would like to deal with contains a list of subroutines and some useless texts.…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
0
votes
2 answers

Conflict while parsing a set of expressions

I would like to parse a set of expressions: R[3]C, R[2]C, R[3]C-R[2]C... There is a conflict I cannot solve... Here is a part of lexer.mll: rule token = parse | 'R' { R } | 'C' { C } | "RC" { RC } |…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
0
votes
1 answer

accessing part of matched string ocamllex

I am trying to arrange for ocamllex and ocamlyacc code to scan and parse a simple language. I have defined the abstract syntax for the same but am finding difficulty scanning for complex rules. Here's my code { type exp = B of bool | Const…
user2352241
  • 81
  • 1
  • 9
0
votes
0 answers

Conflicts in ocamlyacc

I am trying to write a parser for a simple language that recognizes integer and float expressions using ocamlyacc. However I want to introduce the possiblity of having variables. So i defined the token VAR in my lexer.mll file which allows it to be…
Vivek Pradhan
  • 4,777
  • 3
  • 26
  • 46
0
votes
1 answer

How to write a three address code using ocamllex and ocamlyacc?

I was wondering how to write a three address code using ocamllex and ocamlyacc? I googled a lot about this, but I couldn't find anything using ocamlyacc. I have my parser and my lexer working(both using of course ocamlyacc and ocamllex) but now I…
tsukanomon
  • 1,220
  • 1
  • 19
  • 23
-1
votes
1 answer

What does "let name(param1, param2) = .." mean in ocaml (as opposed to just let name = ...)?

I'm looking at a compiler written for a extremely pared down version of C. I'm new to ocaml, and am particularly confused about this structure let check (globals, functions) = (* A bunch of stuff abstracted out *) let check_function ... ....…
Shisui
  • 1,051
  • 1
  • 8
  • 23
-1
votes
1 answer

How can I parse in memory strings (of type String) in OCaml using ocamlyacc?

I have a parser which parses the std input using Ocamlyacc and lex. How can I trigger the start parse rule on a string in OCaml?
abhishek
  • 850
  • 6
  • 14
-1
votes
1 answer

Debug parser by printing useful information

I would like to parse a set of expressions, for instance:X[3], X[-3], XY[-2], X[4]Y[2], etc. In my parser.mly, index (which is inside []) is defined as follows: index: | INTEGER { $1 } | MINUS INTEGER { 0 - $2 } The token INTEGER, MINUS etc. are…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
-2
votes
1 answer

Ocaml syntax error : pattern expected in building zip fuction

I want to make fuction called zip so: zip [1;2;3;4] [5;6;7;8] would produce: [1;5;2;6;3;7;4;8] but I'm getting an error: line#4 h2::t2 make error syntax error : pattern expected What would be the correct syntax? let rec zip lst1 lst2 = match…
1 2 3 4 5
6