Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] ocamllex and yyless, putting back chars in lexbuf

1 view
Skip to first unread message

yoann padioleau

unread,
Nov 12, 2009, 1:47:52 PM11/12/09
to caml...@inria.fr
Hi,

Is there a way in ocamllex to put back certain characters
in the buffer. In flex you can do that

<LOOKING_FOR_XXX>[a-z]+ {
yy_pop_state();
yy_push_state(ST_TOP);
return T_STRING_VARNAME;
}


<LOOKING_FOR_XXX>{ANY_CHAR} {
yyless(0);
yy_pop_state();
yy_push_state(ST_TOP);
}


Should I play with fields like lexbuf_lex_curr_pos ?

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Dario Teixeira

unread,
Nov 12, 2009, 3:32:25 PM11/12/09
to caml...@inria.fr, yoann padioleau
Hi,

> Is there a way in ocamllex to put back certain characters
> in the buffer. In flex you can do that

It is also possible with Ulex, using Ulexing.rollback.

Even if you don't need the UTF8 features, I suggest you take a
look at Ulex anyway; the approach used (it's a syntax extension)
provides greater flexibility. Moreover, it also handles latin1
streams fine.

Cheers,
Dario Teixeira

0 new messages