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
using different lexers with one parser?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-04-17 (20:33)
From: Oliver Bandel <oliver@f...>
Subject: using different lexers with one parser?

using many parsers with ocamlyacc
is possible, because ocamlyacc provides the possibility
forusing moire than one start-token.

Using many lexers is possible with ocamllex,
because each lexer is a seperated function.

Is it possible (without too much effort) to switch
the lexer during parsing (from within the parser)?

Or is better to 
  a) implement calling of different lexers in the *.mll file
  b) use many starting-points of the *.mly-file and
     work on the data from the outside of the parser
     (I'm meaning here: the function that calls the
      yacc-grammar-rule (start-rule)?
     So: does it rather make sense to make a higher-level
     parse on the data that the *.mly-parser gives back?!

BTW: The data (line-based) I want to parse could otherwise
     be parsed relatively easy with regexp's; maybe
     this is the better way?
     Or is there a way to convert such context-dependend
     things to ocamllex/ocamlyacc-syntaxes?
     (It seems to me that similar problems arise, when parsing
      files like picture-files or movie-files (mpg or so).)