Project

General

Profile

« Previous | Next » 

Revision 3dfb5cd8

Added by Lélio Brun over 2 years ago

rewrite a bit the menhir parser

View differences:

src/parsers/lexer_lustre.mll
40 40
  "tel", TEL;
41 41
  "returns", RETURNS;
42 42
  "var", VAR;
43
  "imported", IMPORTED;
43
  (* "imported", IMPORTED; *)
44 44
  "import", IMPORT;
45 45
  "type", TYPE;
46 46
  "int", TINT;
......
90 90
    ANNOT ann
91 91
  with LexerLustreSpec.Error loc -> raise (Parse.Error (Location.shift orig_loc loc, Parse.Annot_error s))
92 92

  
93
let make_spec orig_loc lexbuf s = 
93
let make_spec orig_loc s =
94 94
  try
95 95
    Location.push_loc orig_loc;	
96 96
    let ns = LexerLustreSpec.spec s in
......
208 208
  | _ as c { Buffer.add_char buf c; annot_multiline n lexbuf }
209 209

  
210 210
and spec_singleline loc = parse
211
  | eof { make_spec loc lexbuf (Buffer.contents buf) }
212
  | newline { incr_line lexbuf; make_spec loc lexbuf (Buffer.contents buf) }
211
  | eof { make_spec loc (Buffer.contents buf) }
212
  | newline { incr_line lexbuf; make_spec loc (Buffer.contents buf) }
213 213
  | _ as c { Buffer.add_char buf c; spec_singleline loc lexbuf }
214 214

  
215 215
and spec_multiline loc n = parse
......
217 217
  | "*)" as s { if n > 0 then 
218 218
      (Buffer.add_string buf s; spec_multiline loc (n-1) lexbuf) 
219 219
    else 
220
      make_spec loc lexbuf (Buffer.contents buf) }
220
      make_spec loc (Buffer.contents buf) }
221 221
  | "(*" as s { Buffer.add_string buf s; spec_multiline loc (n+1) lexbuf }
222 222
  | newline as s { incr_line lexbuf; Buffer.add_string buf s; spec_multiline loc n lexbuf }
223 223
  | _ as c { Buffer.add_char buf c; spec_multiline loc n lexbuf }

Also available in: Unified diff