Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] parse <tags>
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <Pietro.Abate@a...>
Subject: [Caml-list] parse <tags>
Hi all,
I'm trying to write a simple parser (below) but I've problems parsing tag-like
keywords. Probably this is a problem related with the lexer. does anybody know
a solution that doesn't imply heavy modifications to the (Genlex) lexer ?

p

code:

#load "camlp4o.cma";;

(* this doesn't work and it's what I want *)
open Genlex;;
let s = "<foo>";;
let flexer = make_lexer [s];;
let s' = flexer (Stream.of_string s);;
let parse_input_line = parser
        [< 'Kwd "<foo>" >] -> Printf.printf "bingo !"
;;
parse_input_line s';;

(* this works, but I want < > !! *)
let s = "foo";;
let flexer = make_lexer [s];;
let s' = flexer (Stream.of_string s);;
let parse_input_line = parser
        [< 'Kwd "foo" >] -> Printf.printf "bingo ?"
;;
parse_input_line s';;

-- 
++ As I grow older, I pay less attention to what men say.
   I just watch what they do. Andrew Carnegie (1835-1919).
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners