ml-lex example doesn't work
Natalia Beatriz Bidart <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm a newbie in ML. I need to build a parser in ML, so I'm learning
ML-Lex and ML-Yacc, but the sample
(http://www.smlnj.org/doc/ML-Lex/manual.html#sample) in the ML-Lex
documentation didn't work. What I got after generate the sml file was:
[bn@DALI lex]$ sml calc.lex.sml
Standard ML of New Jersey v110.52 [built: Sat Jan 29 11:24:27 2005]
[opening calc.lex.sml]
[autoloading]
[autoloading done]
calc.lex.sml:9.22-9.28 Error: unbound variable or constructor: output
calc.lex.sml:9.29-9.36 Error: unbound variable or constructor: std_out
calc.lex.sml:146.43-146.50 Error: unbound variable or constructor: revfold
calc.lex.sml:144.9-144.12 Error: unbound variable or constructor: inc
calc.lex.sml:146.61-146.81 Error: operator and operand don't agree
[tycon mismatch]
operator domain: char
operand: string
in expression:
ord "0"
/usr/local/sml/bin/sml: Fatal error -- Uncaught exception Error with 0
raised at ../compiler/TopLevel/interact/evalloop.sml:63.48-63.56
My first try was to comment the line "val error = fn x =>
output(std_out,x ^ "\n")" and to add a dummy error definition, but I'm
still getting:
[bn@DALI lex]$ sml calc.lex.sml
Standard ML of New Jersey v110.52 [built: Sat Jan 29 11:24:27 2005]
[opening calc.lex.sml]
[autoloading]
[autoloading done]
calc.lex.sml:146.43-146.50 Error: unbound variable or constructor: revfold
calc.lex.sml:144.9-144.12 Error: unbound variable or constructor: inc
calc.lex.sml:146.61-146.81 Error: operator and operand don't agree
[tycon mismatch]
operator domain: char
operand: string
in expression:
ord "0"
calc.lex.sml:152.38-152.84 Error: operator is not a function [tycon
mismatch]
operator: string
in expression:
error ("calc: ignoring bad character " ^ yytext)
/usr/local/sml/bin/sml: Fatal error -- Uncaught exception Error with 0
raised at ../compiler/TopLevel/interact/evalloop.sml:63.48-63.56
So I tried the revfold definition directly in the compiler but:
- revfold;
stdIn:1.1-1.8 Error: unbound variable or constructor: revfold
What I found in http://www.smlnj.org/dist/release/110.0.7/110-HISTORY was:
* the functions List.fold and List.revfold have been replaced by
List.foldr and List.foldl. Furthermore, they have the type:
(('a * 'b) -> 'b) -> 'b -> 'a list -> 'b
I.e., the second and third arguments are swapped.
So I'm wondering if the ML-Lex documentation is out-to-date and I have
to replace the revfold calls for something else, or I'm doing something
wrong, or something is missing (like a library?). I also don't know if
the "output" call is a function or not, if the "std_out" is a definition
or not, etc.
Can you please give a clue? Or a link whith the correct information?
Thanks a lot, Natalia.
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl