ocaml-debugger.opp.exp 3.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
%{

open Int64ops
open Primitives
open Input_handling
open Longident
open Parser_aux

%}
%start argument_eol
%start argument_list_eol
%start break_argument_eol
%start end_of_line
%start expression_list_eol
%start identifier
%start identifier_eol
%start identifier_or_eol
%start int64_eol
%start integer
%start integer_eol
%start integer_list_eol
%start list_arguments_eol
%start longident_eol
%start opt_identifier
%start opt_identifier_eol
%start opt_integer_eol
%start opt_signed_int64_eol
%start opt_signed_integer_eol
%token <string> UIDENT
%token STAR
%token SHARP
%token RPAREN
%token RBRACKET
%token <string> OPERATOR
%token MINUS
%token LPAREN
%token <string> LIDENT
%token LBRACKET
%token <int64> INTEGER
%token EOL
%token DOLLAR
%token AT
%token <string> ARGUMENT
%token DOT
%token BANG
%right DOT 
%right BANG 
%type <string> argument_eol
%type <string list> argument_list_eol
%type <Parser_aux.break_arg> break_argument_eol
%type <unit> end_of_line
%type <Parser_aux.expression list> expression_list_eol
%type <string> identifier
%type <string> identifier_eol
%type <string option> identifier_or_eol
%type <int64> int64_eol
%type <int> integer
%type <int> integer_eol
%type <int list> integer_list_eol
%type <string option * int option * int option> list_arguments_eol
%type <Longident.t> longident_eol
%type <string option> opt_identifier
%type <string option> opt_identifier_eol
%type <int option> opt_integer_eol
%type <int64 option> opt_signed_int64_eol
%type <int option> opt_signed_integer_eol
%%

argument_list_eol:
| ARGUMENT argument_list_eol
    { $1::$2 }
| end_of_line
    { [] }

argument_eol:
| ARGUMENT end_of_line
    { $1 }

integer_list_eol:
| INTEGER integer_list_eol
    { (to_int $1) :: $2 }
| end_of_line
    { [] }

integer_eol:
| INTEGER end_of_line
    { to_int $1 }

int64_eol:
| INTEGER end_of_line
    { $1 }

integer:
| INTEGER
    { to_int $1 }

opt_integer_eol:
| INTEGER end_of_line
    { Some (to_int $1) }
| end_of_line
    { None }

opt_int64_eol:
| INTEGER end_of_line
    { Some $1 }
| end_of_line
    { None }

opt_signed_integer_eol:
| MINUS integer_eol
    { Some (- $2) }
| opt_integer_eol
    { $1 }

opt_signed_int64_eol:
| MINUS int64_eol
    { Some (Int64.neg $2) }
| opt_int64_eol
    { $1 }

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:
| longident end_of_line
    { $1 }

identifier:
| LIDENT
    { $1 }
| UIDENT
    { $1 }

identifier_eol:
| identifier end_of_line
    { $1 }

identifier_or_eol:
| identifier
    { Some $1 }
| end_of_line
    { None }

opt_identifier:
| identifier
    { Some $1 }
| 
    { None }

opt_identifier_eol:
| opt_identifier end_of_line
    { $1 }

expression:
| longident
    { E_ident $1 }
| STAR
    { E_result }
| 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)) }
| expression DOT LIDENT
    { E_field($1, $3) }
| BANG expression
    { E_field($2, "contents") }
| LPAREN expression RPAREN
    { $2 }

expression_list_eol:
| expression expression_list_eol
    { $1::$2 }
| end_of_line
    { [] }

break_argument_eol:
| end_of_line
    { BA_none }
| integer_eol
    { BA_pc $1 }
| expression end_of_line
    { BA_function $1 }
| AT opt_identifier INTEGER opt_integer_eol
    { BA_pos1 ($2, (to_int $3), $4)}
| AT opt_identifier SHARP integer_eol
    { BA_pos2 ($2, $4) }

list_arguments_eol:
| opt_identifier integer opt_integer_eol
    { ($1, Some $2, $3) }
| opt_identifier_eol
    { ($1, None, None) }

end_of_line:
| EOL
    { stop_user_input () }

%%