List Info

Thread: RE: "ocaml_beginners"::[] match ... with parser syntax?




RE: "ocaml_beginners"::[] match ... with parser syntax?
user name
2007-01-28 14:11:52

Thanks.

Okay, I'm starting the interpreter with "ocaml -I +camlp4 camlp4o.cma" This
gets me a little further but now I get the following error:

Objective Caml version 3.09.0

Camlp4 Parsing version 3.09.0

# let rec spaces s =

match s with parser

[<'' ' ; rest >] -> spaces rest

| [<''t' ; rest >] -> spaces rest

| [<''n' ; rest >] -> spaces rest

| [<>] -> ();;

val spaces : char Stream.t -> unit = <fun>;

# let rec lexer s =

spaces s;

match s with parser

[< ''(' >] -> [< 'Lsymbol "(&quot; ; lexer s >]

| [< '')' >] -> [< 'Lsymbol ")&quot; ; lexer s >]

| [< ''+' >] -> [< 'Lsymbol "+&quot; ; lexer s >]

| [< ''-' >] -> [< 'Lsymbol "-&quot; ; lexer s >]

| [< ''*' >] -> [< 'Lsymbol "*&quot; ; lexer s >]

| [< ''/' >] -> [< 'Lsymbol "/&quot; ; lexer s >]

| [< ''0'..'9' as c;

i,v = lexint (Char.code c - Char.code('0')) >]

->; [<'Lint i ; lexer v>]

and lexint r s =

match s with parser

[<; ''0'..'9' as c >]

->; let u = (Char.code c) - (Char.code '0') in lexint (10*r + u) s

| [<>] -> r,s;;

Characters 78-89:

[< ''(' >] -> [< 'Lsymbol "(&quot; ; lexer s >]

^^^^^^^^^^^

Unbound constructor Lsymbol

#

_____

From: ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com
[mailto: ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com] On Behalf Of Jonathan Roewen
Sent: Wednesday, January 24, 2007 7:53 PM
To: ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com
Subject: Re: "ocaml_beginners"::[] match ... with parser syntax?

Need to load/compile with camlp4o.cma. Parser syntax is no longer
enabled by default.

On 1/25/07, Grant Olson <olsongtverizon. <mailto:olsongt%40verizon.net>
net> wrote:
&gt; I'm working through the translation of the O'Reilly book, and I'm
currently
>; at the chapter on lexing and parsing. The code from the following section
> doesn't seem to work for me:
>
> http://caml.
<fonctions">http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora105.html#fonctions
3> inria.fr/pub/docs/oreilly-book/html/book-ora105.html#fonctions3
> 50
>
> I've tried both typing it in manually, and cut-n-pasting from the html.
Has
> the syntax changed in ocaml 3.0? Did latex botch something, like showing a
> single tick instead of a backtick? Or am I just doing something stupid on
my
> system?
>
> I'm evaluating with M-C-x in tuareg-mode if that makes a difference.
>
> Any help or pointers to reference materials would be appreciated,
>
> Grant
&gt;
>
>
>; Archives up to November 11, 2006 are also downloadable at
http://www.connetti <http://www.connettivo.net/cntprojects/ocaml_beginners/>
vo.net/cntprojects/ocaml_beginners/
> The archives of the very official ocaml list (the seniors' one) can be
found at http://caml. <http://caml.inria.fr> inria.fr
> Attachments are banned and you're asked to be polite, avoid flames etc.
>; Yahoo! Groups Links
&gt;
>
>
>;

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] match ... with parser syntax?
user name
2007-01-28 14:24:01

I don't see any statements opening a module which may define the type
constructor Lsymobl =P

I assume it's something like type t = Lsymbol of string | Lint of int ...

For instance, if this were in a module, say, types.ml, that's been
compiled already, then you need an 'open Types' statement (this brings
symbols in the named module into scope).

In the toplevel, you can also use the directive #use "filename";;
where filename is path to an ocaml source file. This does textual
inclusion, and the code is evaluated by the toplevel, results printed,
and bindings created.

Jonathan

On 1/29/07, Grant Olson < olsongt%40verizon.net">olsongtverizon.net> wrote:
&gt; Thanks.
>
>
>
&gt; Okay, I'm starting the interpreter with "ocaml -I +camlp4 camlp4o.cma" This
>; gets me a little further but now I get the following error:
&gt;
>
>
&gt; Objective Caml version 3.09.0
&gt;
>
>
&gt; Camlp4 Parsing version 3.09.0
&gt;
>
>
&gt; # let rec spaces s =
>
> match s with parser
&gt;
> [<'' ' ; rest >] -> spaces rest
>;
> | [<''t' ; rest >] -> spaces rest
>;
> | [<''n' ; rest >] -> spaces rest
>;
> | [<>] -> ();;
>;
> val spaces : char Stream.t -> unit = <fun>;
>
> # let rec lexer s =
>
> spaces s;
>
> match s with parser
&gt;
> [< ''(' >] -> [< 'Lsymbol "(&quot; ; lexer s >]
&gt;
> | [< '')' >] -> [< 'Lsymbol ")&quot; ; lexer s >]
&gt;
> | [< ''+' >] -> [< 'Lsymbol "+&quot; ; lexer s >]
&gt;
> | [< ''-' >] -> [< 'Lsymbol "-&quot; ; lexer s >]
&gt;
> | [< ''*' >] -> [< 'Lsymbol "*&quot; ; lexer s >]
&gt;
> | [< ''/' >] -> [< 'Lsymbol "/&quot; ; lexer s >]
&gt;
> | [< ''0'..'9' as c;
>
> i,v = lexint (Char.code c - Char.code('0')) >]
&gt;
> -> [<'Lint i ; lexer v>]
&gt;
> and lexint r s =
>
> match s with parser
&gt;
> [< ''0'..'9' as c >]
&gt;
> -> let u = (Char.code c) - (Char.code '0') in lexint (10*r + u) s
>
> | [<>] -> r,s;;
&gt;
> Characters 78-89:
&gt;
> [< ''(' >] -> [< 'Lsymbol "(&quot; ; lexer s >]
&gt;
> ^^^^^^^^^^^
>
> Unbound constructor Lsymbol
>
> #
>
>
>;
> _____
&gt;
> From: ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com
> [mailto: ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com] On Behalf Of Jonathan Roewen
&gt; Sent: Wednesday, January 24, 2007 7:53 PM
> To: ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com
> Subject: Re: "ocaml_beginners"::[] match ... with parser syntax?
>
>
>
&gt; Need to load/compile with camlp4o.cma. Parser syntax is no longer
&gt; enabled by default.
>
>; On 1/25/07, Grant Olson <olsongtverizon. <mailto:olsongt%40verizon.net>
&gt; net> wrote:
&gt; > I'm working through the translation of the O'Reilly book, and I'm
> currently
> > at the chapter on lexing and parsing. The code from the following section
> > doesn't seem to work for me:
> >
>; > http://caml.
> <fonctions">http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora105.html#fonctions
> 3> inria.fr/pub/docs/oreilly-book/html/book-ora105.html#fonctions3
> > 50
> >
>; > I've tried both typing it in manually, and cut-n-pasting from the html.
&gt; Has
> > the syntax changed in ocaml 3.0? Did latex botch something, like showing a
> > single tick instead of a backtick? Or am I just doing something stupid on
> my
> > system?
> >
>; > I'm evaluating with M-C-x in tuareg-mode if that makes a difference.
> >
>; > Any help or pointers to reference materials would be appreciated,
> >
>; > Grant
&gt; >
>; >
>; >
>; > Archives up to November 11, 2006 are also downloadable at
> http://www.connetti <http://www.connettivo.net/cntprojects/ocaml_beginners/>
> vo.net/cntprojects/ocaml_beginners/
> > The archives of the very official ocaml list (the seniors' one) can be
> found at http://caml. <http://caml.inria.fr> inria.fr
> > Attachments are banned and you're asked to be polite, avoid flames etc.
>; > Yahoo! Groups Links
&gt; >
>; >
>; >
>; >
>;
>
>
>
>
&gt; [Non-text portions of this message have been removed]
>
>;
>
> Archives up to November 11, 2006 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
> The archives of the very official ocaml list (the seniors' one) can be found at http://caml.inria.fr
> Attachments are banned and you're asked to be polite, avoid flames etc.
>; Yahoo! Groups Links
&gt;
>
>
>;

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )