Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamllex and python-style indentation
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mike Lin <nilekim@g...>
Subject: Re: [Caml-list] ocamllex and python-style indentation
That's cheating!!!!!! It's clever :) But clearly, you have a little
parser with a stack there. My original contribution to this thread was
just that "you've got to lex and parse at some level" before doing the
whitespace conversion. Not that you were claiming otherwise, but it
seemed like others had alluded to simpler ways which would only work
for toy languages.


On Wed, Jul 1, 2009 at 10:21 AM, Andreas Rossberg<rossberg@mpi-sws.org> wrote:
> I wrote:
>>
>> ------------------------------------------------
>> let error l s = (* ... *)
>> let commentDepth = ref 0
>> let start = ref 0
>> let loc length = let pos = !start in (pos, pos+length)
>>
>> rule lex =
>>   parse eof            { EOF }
>>   (* | ... *)
>>   | "{-"            { start := pos lexbuf;
>>                 lexNestComment lexbuf }
>
> Sorry, the "{-" should be "(*" for ML. And the (* | ... *) is supposed to
> stand for all other tokens in your lexer.
>
> - Andreas
>
>