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$ */
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
2002-10-29 09:53:24 -08:00
|
|
|
open Int64ops
|
1997-01-04 08:57:00 -08:00
|
|
|
open Input_handling
|
1997-01-05 06:04:06 -08:00
|
|
|
open Longident
|
1997-01-04 08:57:00 -08:00
|
|
|
open Parser_aux
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
1997-05-19 08:42:21 -07:00
|
|
|
%token <string> ARGUMENT
|
|
|
|
%token <string> LIDENT
|
|
|
|
%token <string> UIDENT
|
|
|
|
%token <string> OPERATOR
|
2002-10-29 09:53:24 -08:00
|
|
|
%token <int64> INTEGER
|
1997-05-19 08:42:21 -07:00
|
|
|
%token STAR /* * */
|
|
|
|
%token MINUS /* - */
|
|
|
|
%token DOT /* . */
|
|
|
|
%token SHARP /* # */
|
|
|
|
%token AT /* @ */
|
|
|
|
%token DOLLAR /* $ */
|
|
|
|
%token BANG /* ! */
|
|
|
|
%token LPAREN /* ( */
|
|
|
|
%token RPAREN /* ) */
|
|
|
|
%token LBRACKET /* [ */
|
|
|
|
%token RBRACKET /* ] */
|
|
|
|
%token EOL
|
1997-01-04 08:57:00 -08:00
|
|
|
|
1997-01-05 06:04:06 -08:00
|
|
|
%right DOT
|
|
|
|
%right BANG
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
%start argument_list_eol
|
|
|
|
%type <string list> argument_list_eol
|
|
|
|
|
|
|
|
%start argument_eol
|
|
|
|
%type <string> argument_eol
|
|
|
|
|
|
|
|
%start integer_list_eol
|
|
|
|
%type <int list> integer_list_eol
|
|
|
|
|
|
|
|
%start integer_eol
|
|
|
|
%type <int> integer_eol
|
|
|
|
|
2002-10-29 09:53:24 -08:00
|
|
|
%start int64_eol
|
|
|
|
%type <int64> int64_eol
|
|
|
|
|
1997-01-04 08:57:00 -08:00
|
|
|
%start integer
|
|
|
|
%type <int> integer
|
|
|
|
|
|
|
|
%start opt_integer_eol
|
|
|
|
%type <int option> opt_integer_eol
|
|
|
|
|
|
|
|
%start opt_signed_integer_eol
|
|
|
|
%type <int option> opt_signed_integer_eol
|
|
|
|
|
2002-10-29 09:53:24 -08:00
|
|
|
%start opt_signed_int64_eol
|
|
|
|
%type <int64 option> opt_signed_int64_eol
|
|
|
|
|
1997-01-04 08:57:00 -08:00
|
|
|
%start identifier
|
|
|
|
%type <string> identifier
|
|
|
|
|
|
|
|
%start identifier_eol
|
|
|
|
%type <string> identifier_eol
|
|
|
|
|
|
|
|
%start identifier_or_eol
|
|
|
|
%type <string option> identifier_or_eol
|
|
|
|
|
1997-01-05 06:04:06 -08:00
|
|
|
%start opt_identifier
|
|
|
|
%type <string option> opt_identifier
|
|
|
|
|
1997-01-04 08:57:00 -08:00
|
|
|
%start opt_identifier_eol
|
|
|
|
%type <string option> opt_identifier_eol
|
|
|
|
|
1997-01-05 06:04:06 -08:00
|
|
|
%start expression_list_eol
|
|
|
|
%type <Parser_aux.expression list> expression_list_eol
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
%start break_argument_eol
|
|
|
|
%type <Parser_aux.break_arg> break_argument_eol
|
|
|
|
|
|
|
|
%start list_arguments_eol
|
2009-05-20 04:52:42 -07:00
|
|
|
%type <Longident.t option * int option * int option> list_arguments_eol
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
%start end_of_line
|
|
|
|
%type <unit> end_of_line
|
|
|
|
|
1997-02-14 08:30:00 -08:00
|
|
|
%start longident_eol
|
|
|
|
%type <Longident.t> longident_eol
|
|
|
|
|
2009-05-20 04:52:42 -07:00
|
|
|
%start opt_longident
|
|
|
|
%type <Longident.t option> opt_longident
|
|
|
|
|
|
|
|
%start opt_longident_eol
|
|
|
|
%type <Longident.t option> opt_longident_eol
|
|
|
|
|
1997-01-04 08:57:00 -08:00
|
|
|
%%
|
|
|
|
|
|
|
|
/* Raw arguments */
|
|
|
|
|
|
|
|
argument_list_eol :
|
|
|
|
ARGUMENT argument_list_eol
|
|
|
|
{ $1::$2 }
|
|
|
|
| end_of_line
|
|
|
|
{ [] };
|
|
|
|
|
|
|
|
argument_eol :
|
|
|
|
ARGUMENT end_of_line
|
|
|
|
{ $1 };
|
|
|
|
|
|
|
|
/* Integer */
|
|
|
|
|
|
|
|
integer_list_eol :
|
|
|
|
INTEGER integer_list_eol
|
2002-10-29 09:53:24 -08:00
|
|
|
{ (to_int $1) :: $2 }
|
1997-01-04 08:57:00 -08:00
|
|
|
| end_of_line
|
|
|
|
{ [] };
|
|
|
|
|
|
|
|
integer_eol :
|
2002-10-29 09:53:24 -08:00
|
|
|
INTEGER end_of_line
|
|
|
|
{ to_int $1 };
|
|
|
|
|
|
|
|
int64_eol :
|
1997-01-04 08:57:00 -08:00
|
|
|
INTEGER end_of_line
|
|
|
|
{ $1 };
|
|
|
|
|
|
|
|
integer :
|
|
|
|
INTEGER
|
2002-10-29 09:53:24 -08:00
|
|
|
{ to_int $1 };
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
opt_integer_eol :
|
2002-10-29 09:53:24 -08:00
|
|
|
INTEGER end_of_line
|
|
|
|
{ Some (to_int $1) }
|
|
|
|
| end_of_line
|
|
|
|
{ None };
|
|
|
|
|
|
|
|
opt_int64_eol :
|
1997-01-04 08:57:00 -08:00
|
|
|
INTEGER end_of_line
|
|
|
|
{ Some $1 }
|
|
|
|
| end_of_line
|
|
|
|
{ None };
|
|
|
|
|
|
|
|
opt_signed_integer_eol :
|
|
|
|
MINUS integer_eol
|
|
|
|
{ Some (- $2) }
|
|
|
|
| opt_integer_eol
|
|
|
|
{ $1 };
|
|
|
|
|
2002-10-29 09:53:24 -08:00
|
|
|
opt_signed_int64_eol :
|
|
|
|
MINUS int64_eol
|
|
|
|
{ Some (Int64.neg $2) }
|
|
|
|
| opt_int64_eol
|
|
|
|
{ $1 };
|
|
|
|
|
1997-01-05 06:04:06 -08:00
|
|
|
/* Identifiers and long identifiers */
|
|
|
|
|
|
|
|
longident :
|
|
|
|
LIDENT { Lident $1 }
|
|
|
|
| module_path DOT LIDENT { Ldot($1, $3) }
|
|
|
|
| OPERATOR { Lident $1 }
|
|
|
|
;
|
|
|
|
|
|
|
|
module_path :
|
|
|
|
UIDENT { Lident $1 }
|
|
|
|
| module_path DOT UIDENT { Ldot($1, $3) }
|
|
|
|
;
|
|
|
|
|
|
|
|
longident_eol :
|
2009-05-20 04:52:42 -07:00
|
|
|
longident end_of_line { $1 };
|
|
|
|
|
|
|
|
opt_longident :
|
|
|
|
UIDENT { Some (Lident $1) }
|
|
|
|
| module_path DOT UIDENT { Some (Ldot($1, $3)) }
|
|
|
|
| { None };
|
|
|
|
|
|
|
|
opt_longident_eol :
|
|
|
|
opt_longident end_of_line { $1 };
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
identifier :
|
1997-01-05 06:04:06 -08:00
|
|
|
LIDENT { $1 }
|
|
|
|
| UIDENT { $1 };
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
identifier_eol :
|
1997-01-05 06:04:06 -08:00
|
|
|
identifier end_of_line { $1 };
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
identifier_or_eol :
|
1997-01-05 06:04:06 -08:00
|
|
|
identifier { Some $1 }
|
|
|
|
| end_of_line { None };
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
opt_identifier :
|
1997-01-05 06:04:06 -08:00
|
|
|
identifier { Some $1 }
|
|
|
|
| { None };
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
opt_identifier_eol :
|
1997-01-05 06:04:06 -08:00
|
|
|
opt_identifier end_of_line { $1 };
|
|
|
|
|
|
|
|
/* Expressions */
|
|
|
|
|
|
|
|
expression:
|
|
|
|
longident { E_ident $1 }
|
|
|
|
| STAR { E_result }
|
2002-10-29 09:53:24 -08:00
|
|
|
| DOLLAR INTEGER { E_name (to_int $2) }
|
|
|
|
| expression DOT INTEGER { E_item($1, (to_int $3)) }
|
|
|
|
| expression DOT LBRACKET INTEGER RBRACKET { E_item($1, (to_int $4)) }
|
|
|
|
| expression DOT LPAREN INTEGER RPAREN { E_item($1, (to_int $4)) }
|
1997-01-05 06:04:06 -08:00
|
|
|
| expression DOT LIDENT { E_field($1, $3) }
|
|
|
|
| BANG expression { E_field($2, "contents") }
|
|
|
|
| LPAREN expression RPAREN { $2 }
|
|
|
|
;
|
1997-01-04 08:57:00 -08:00
|
|
|
|
1997-01-05 06:04:06 -08:00
|
|
|
/* Lists of expressions */
|
1997-01-04 08:57:00 -08:00
|
|
|
|
1997-01-05 06:04:06 -08:00
|
|
|
expression_list_eol :
|
|
|
|
expression expression_list_eol { $1::$2 }
|
|
|
|
| end_of_line { [] }
|
|
|
|
;
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
/* Arguments for breakpoint */
|
|
|
|
|
|
|
|
break_argument_eol :
|
1997-01-05 06:04:06 -08:00
|
|
|
end_of_line { BA_none }
|
|
|
|
| integer_eol { BA_pc $1 }
|
1997-02-19 08:09:23 -08:00
|
|
|
| expression end_of_line { BA_function $1 }
|
2009-05-20 04:52:42 -07:00
|
|
|
| AT opt_longident INTEGER opt_integer_eol { BA_pos1 ($2, (to_int $3), $4)}
|
|
|
|
| AT opt_longident SHARP integer_eol { BA_pos2 ($2, $4) }
|
1997-01-05 06:04:06 -08:00
|
|
|
;
|
1997-01-04 08:57:00 -08:00
|
|
|
|
|
|
|
/* Arguments for list */
|
|
|
|
|
|
|
|
list_arguments_eol :
|
2009-05-20 04:52:42 -07:00
|
|
|
opt_longident integer opt_integer_eol
|
1997-01-04 08:57:00 -08:00
|
|
|
{ ($1, Some $2, $3) }
|
2009-05-20 04:52:42 -07:00
|
|
|
| opt_longident_eol
|
1997-01-04 08:57:00 -08:00
|
|
|
{ ($1, None, None) };
|
|
|
|
|
|
|
|
/* End of line */
|
|
|
|
|
|
|
|
end_of_line :
|
1997-01-05 06:04:06 -08:00
|
|
|
EOL { stop_user_input () }
|
|
|
|
;
|