Below is the file 'revision_lexer.mll' from this revision. You can also download the file.


{
  open Revision_parser

  let kwd = Hashtbl.create 37

  let _ =
    List.iter (fun (k, tok) -> Hashtbl.add kwd k tok)
      [ "new_manifest", NEW_MANIFEST;
        "old_revision", OLD_REVISION;
        "old_manifest", OLD_MANIFEST;
	"patch", PATCH;
	"from", FROM;
	"to", TO;
        "add_file", ADD_FILE;
        "delete_file", DELETE_FILE;
        "delete_dir", DELETE_DIR;
        "rename_file", RENAME_FILE;
        "rename_dir", RENAME_DIR; ]
}

let id = ['a'-'z' '0'-'9']*
let ident = ['a'-'z' '_']+

rule lex = parse
  | [ ' ' '\n' '\t']+   { lex lexbuf }
  | '[' (id as id) ']'  { ID id }
  | ident               { try Hashtbl.find kwd (Lexing.lexeme lexbuf)
                          with Not_found -> raise Parsing.Parse_error }
  | '"'                 { STRING (string (Buffer.create 128) lexbuf) }
  | eof                 { EOF }

and string b = parse
  | '"'     { Buffer.contents b }
  | "\\\""  { Buffer.add_char b '"' ; string b lexbuf }
  | _       { Buffer.add_char b (Lexing.lexeme_char lexbuf 0) ;
              string b lexbuf }