On 13-10-2010, Ivo Seeba <[email protected]> wrote:
> --0015174c123e0fc5aa04927cfb66
> Content-Type: text/plain; charset=ISO-8859-1
>
> One question,how to compile that it recognizes "[<..>]" ?
>
> open Genlex;;
> let keywords = [
>     "REM"; "GOTO"; "LET"; "PRINT"; "INPUT"; "IF"; "THEN";
>     "-"; "!"; "+"; "-"; "*"; "/"; "%";
>     "="; "<"; ">"; "<="; ">="; "<>";
>     "&"; "|"
> ];;
> (*takes as input a string of characters and returns the corresponding
> stream of lexemes.*)
> let line_lexer l =
>     make_lexer keywords (Stream.of_string l) ;;
>
> line_lexer "LET x = x + y * 3" ;;
>
> let rec spaces s =
> match s with parser
>| [<'' ' ; rest >] -> spaces rest    (* this is the line 14*)
>| [<''\t' ; rest >] -> spaces rest
>| [<''\n' ; rest >] -> spaces rest
>| [<>] -> () ;;
>
> $ ocaml toolsForLexical.ml
> File "toolsForLexical.ml", line 14, characters 2-4:
> Error: Syntax error
>

The parser streams are defined using camlp4. It you want to compile the
example above, use the following:
$ ocamlfind ocamlc -syntax camlp4o -package camlp4 test.ml 

N.B. you need findlib, which is a quite common program to compile OCaml
code (should be easy to found on Linux distribution)

N.B.2: ocaml interpret your code, it doesn't really compile it -- on
disk. ocamlc is the compiler that can generate an executable.

Regards
Sylvain Le Gall

-- 
You received this message because you are subscribed to the Google Groups 
"ocaml-developer" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/ocaml-developer?hl=en
For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html

Reply via email to