1997-01-04 08:57:00 -08:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Objective Caml *)
|
|
|
|
(* *)
|
|
|
|
(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* Objective Caml port by John Malecki and Xavier Leroy *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1997-01-04 08:57:00 -08:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
open Primitives
|
|
|
|
open Parser
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1997-05-19 08:42:21 -07:00
|
|
|
rule line = (* Read a whole line *)
|
1997-01-04 08:57:00 -08:00
|
|
|
parse
|
|
|
|
[ ^ '\n' ]* '\n'
|
1997-01-05 06:04:06 -08:00
|
|
|
{ let line = Lexing.lexeme lexbuf in
|
|
|
|
String.sub line 0 (String.length line - 1) }
|
1997-01-04 08:57:00 -08:00
|
|
|
| [ ^ '\n' ]*
|
|
|
|
{ Lexing.lexeme lexbuf }
|
|
|
|
| eof
|
|
|
|
{ raise Exit }
|
|
|
|
|
1997-05-19 08:42:21 -07:00
|
|
|
and argument = (* Read a raw argument *)
|
1997-01-04 08:57:00 -08:00
|
|
|
parse
|
|
|
|
[ ^ ' ' '\t' ]+
|
|
|
|
{ ARGUMENT (Lexing.lexeme lexbuf) }
|
|
|
|
| [' ' '\t']+
|
|
|
|
{ argument lexbuf }
|
|
|
|
| eof
|
|
|
|
{ EOL }
|
|
|
|
| _
|
|
|
|
{ raise Parsing.Parse_error }
|
|
|
|
|
|
|
|
and line_argument =
|
|
|
|
parse
|
1997-01-05 06:04:06 -08:00
|
|
|
_ *
|
1997-01-04 08:57:00 -08:00
|
|
|
{ ARGUMENT (Lexing.lexeme lexbuf) }
|
|
|
|
| eof
|
|
|
|
{ EOL }
|
|
|
|
|
1997-05-19 08:42:21 -07:00
|
|
|
and lexeme = (* Read a lexeme *)
|
1997-01-04 08:57:00 -08:00
|
|
|
parse
|
|
|
|
[' ' '\t'] +
|
|
|
|
{ lexeme lexbuf }
|
1999-05-15 08:09:35 -07:00
|
|
|
| ['a'-'z' '\223'-'\246' '\248'-'\255' '_']
|
1997-01-05 06:04:06 -08:00
|
|
|
(['A'-'Z' 'a'-'z' '_' '\192'-'\214' '\216'-'\246' '\248'-'\255'
|
|
|
|
'\'' '0'-'9' ]) *
|
|
|
|
{ LIDENT(Lexing.lexeme lexbuf) }
|
|
|
|
| ['A'-'Z' '\192'-'\214' '\216'-'\222' ]
|
|
|
|
(['A'-'Z' 'a'-'z' '_' '\192'-'\214' '\216'-'\246' '\248'-'\255'
|
|
|
|
'\'' '0'-'9' ]) *
|
|
|
|
{ UIDENT(Lexing.lexeme lexbuf) }
|
1997-02-25 06:40:10 -08:00
|
|
|
| '"' [^ '"']* "\""
|
|
|
|
{ let s = Lexing.lexeme lexbuf in
|
|
|
|
LIDENT(String.sub s 1 (String.length s - 2)) }
|
1997-01-04 08:57:00 -08:00
|
|
|
| ['0'-'9']+
|
|
|
|
| '0' ['x' 'X'] ['0'-'9' 'A'-'F' 'a'-'f']+
|
|
|
|
| '0' ['o' 'O'] ['0'-'7']+
|
|
|
|
| '0' ['b' 'B'] ['0'-'1']+
|
|
|
|
{ INTEGER (int_of_string (Lexing.lexeme lexbuf)) }
|
|
|
|
| '*'
|
|
|
|
{ STAR }
|
|
|
|
| "-"
|
|
|
|
{ MINUS }
|
1997-01-05 06:04:06 -08:00
|
|
|
| "."
|
|
|
|
{ DOT }
|
1997-01-04 08:57:00 -08:00
|
|
|
| "#"
|
|
|
|
{ SHARP }
|
|
|
|
| "@"
|
|
|
|
{ AT }
|
1997-01-05 06:04:06 -08:00
|
|
|
| "$"
|
|
|
|
{ DOLLAR }
|
|
|
|
| "!"
|
|
|
|
{ BANG }
|
1997-01-04 08:57:00 -08:00
|
|
|
| "("
|
|
|
|
{ LPAREN }
|
|
|
|
| ")"
|
|
|
|
{ RPAREN }
|
|
|
|
| "["
|
|
|
|
{ LBRACKET }
|
|
|
|
| "]"
|
|
|
|
{ RBRACKET }
|
1997-01-05 06:04:06 -08:00
|
|
|
| ['!' '?' '~' '=' '<' '>' '|' '&' '$' '@' '^' '+' '-' '*' '/' '%']
|
|
|
|
['!' '$' '%' '&' '*' '+' '-' '.' '/' ':' '<' '=' '>' '?' '@' '^' '|' '~'] *
|
1997-01-04 08:57:00 -08:00
|
|
|
{ OPERATOR (Lexing.lexeme lexbuf) }
|
|
|
|
| eof
|
|
|
|
{ EOL }
|
|
|
|
| _
|
|
|
|
{ raise Parsing.Parse_error }
|