Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: The lexer hack
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-11-10 (16:26)
From: Dario Teixeira <darioteixeira@y...>
Subject: Re: [Caml-list] Re: The lexer hack

> You could write your lexers in Menhir and make them part of
> your grammar. I know this isn't a terribly easy solution but
> it would be elegant IMO.

I thought of scannerless parsing, but the input is UTF8 encoded,
which makes using Ulex all the more convenient and less error-prone.

Anyway, I was looking at Dypgen's early actions, and an idea
occurred to me: I can create dummy empty actions that simply
change a global "parsing context" variable:

  | (...)
  | BEGIN_VERB enter_verb RAW END_VERB exit_verb {Ast.Verbatim $3}
  | (...)

enter_verb:  /* empty */  {Global.context := Global.Verbatim}
exit_verb:   /* empty */  {Global.context := Global.General}

Still hackish, but better than creating a state machine...

Dario Teixeira