Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Dario Teixeira <darioteixeira@y...>
Subject: Re: [Caml-list] Re: The lexer hack
Hi,

> 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:

inline:
  | (...)
  | 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...

Cheers,
Dario Teixeira