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

expand ocamllex for a bigger lexicon

is there a way to get ocammlex work with more keywords? i've written an interpreter and parser for the german language, which "compiles" german text into latex-pictures for sake of language analysis. it works really fine and is really new in the…
2
votes
2 answers

OCaml parser for :: case

I'm having trouble with associativity. For some reason my = operator has higher precedence than my :: operator So for instance, if I have "1::[] = []" in as a string, I would get 1 = []::[] as my expression instead of [1] = [] If my string…
Sugihara
  • 1,091
  • 2
  • 20
  • 35
2
votes
1 answer

Precedence in parsing

I reformulate a question I asked previously. The purpose is to understand how precedence works in parsing. I would like to parse a statement a(3).value = 100. parser.mly as follows stops after reading ., and returns an error. However, if I move the…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
2
votes
1 answer

OCaml parser code

My code: Term : ... | VAR { try Hashtbl.find var_table $1 with Not_found -> printf "no such variable '%s'\n" $1; 0.0 } /*(Line:75)*/ ... and when I was run it, under ocamlc -c parser.ml I see: Error: This expression has type…
Vandermond
  • 23
  • 4
2
votes
2 answers

External definitions for ocamllex regular expressions

I have implemented the usual combination of lexer/parser/pretty-printer for reading-in/printing a type in my code. I find there is redundancy among the lexer and the pretty-printer when it comes to plain-string regular expressions, usually employed…
Nikos
  • 219
  • 1
  • 8
2
votes
2 answers

Embedding a domain specific language in an OCaml toplevel -- to Camlp4 or not?

I have some code that includes a menhir-based parser for a domain specific language (a logic). For the sake of my sanity while debugging, it would be great to be able to type instances of this language (formulas) directly in the toplevel like so: #…
Nikos
  • 219
  • 1
  • 8
1
vote
1 answer

What is this Ocaml code written to generate LLVM IR doing?

I am new to Ocaml and don't understand what this block of code is doing let global_vars : L.llvalue StringMap.t = let global_var m (t, n) = let init = match t with A.Float -> L.const_float (ltype_of_typ t) 0.0 | _ ->…
Shisui
  • 1,051
  • 1
  • 8
  • 23
1
vote
1 answer

Does precedence matter in ocaml parser?

For example if I was writing a parser.mly file like, and I have this written for expressions expr: expr PLUS expr { Binop($1, Add, $3) } | expr DIVIDE expr { Binop($1, Divide, $3) } Would this be the same as expr: expr DIVIDE …
Shisui
  • 1,051
  • 1
  • 8
  • 23
1
vote
1 answer

Transition table overflow, automaton is too big

I want to add the support of structured references with Excel tables to my lexer & parser of Excel formulas. I added the following regular expressions to lexer_structref.mll: let lex_table_name = "DeptSales" let lex_column_header = "Sales…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
1
vote
1 answer

How to generate a proper makefile for an Ocaml project

I am learning how to compilers work. I read a tutorial on how to use Ocamllex and Ocamlyacc to read an input from a source code, generate the tokens and generate a syntatic tree in order to compute the execution of the program later. I had to…
Sev
  • 195
  • 3
  • 10
1
vote
0 answers

Extract Token List from OCamllex lexbuf

I am writing a Python interpreter in OCaml using ocamllex, and in order to handle the indentation-based syntax, I want to tokenize the input using ocamllex iterate through the list of lexed tokens and insert INDENT and DEDENT tokens as needed for…
JAustin
  • 890
  • 10
  • 16
1
vote
1 answer

Ocaml parser "unterminated action" error

I am new to OCaml and I am trying to create a Parser for a specific language using a parser generator - ocamllex, ocamlyacc. When i'm trying to compile my parser.mly file, I am getting the following error: Error (with mark at =) : File "parser.mly",…
denbuttigieg
  • 185
  • 1
  • 1
  • 12
1
vote
1 answer

OCAML Taking multiple arguments from stdin and operating on them one by one

I have written an interpreter using ocamllex and ocamlyacc, the lexer and the parser work correctly but currently they only parse the last .txt argument it receives as oppose to all of them in turn. For example, ./interpret one.txt two.txt three.txt…
1
vote
1 answer

What does :: (double colon) mean in Ocaml?

formal_list: typ ID { [($1,$2)] } | formal_list COMMA typ ID { ($3,$4) :: $1 } What does the :: operator mean? For instance: a :: b Is the meaning that we add a to b?
janepoor
  • 31
  • 1
  • 2
1
vote
1 answer

Get the input string that raises parsing error inside the parser

I have a frontend written in menhir which tries to parse an expression: from a string to an expression AST. The entry point of the frontend Parser_e.main is called in several different places in my OCaml code. So I would like to be able to catch…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292