Skip to content
This repository
Browse code

[fix] compiler, syntax: Adding local binding directives

  • Loading branch information...
commit 34dba1fd72614939e8ccdefd3714f9a0ffc0f983 1 parent 32ca507
Quentin Bourgerie BourgerieQuentin authored
2  opalang/classic_syntax/parser_utils.ml
@@ -504,6 +504,8 @@ let one_declaration_directive (((dir:parsing_directive),l,lt), label) bindings =
504 504 (p,e)) bindings
505 505 let declaration_directive dirs bindings =
506 506 List.fold_right one_declaration_directive dirs bindings
  507 +let declaration_directive_1 dirs binding =
  508 + List.hd (declaration_directive dirs [binding])
507 509
508 510
509 511 (*
3  opalang/classic_syntax/parser_utils.mli
@@ -373,6 +373,9 @@ val double_dot : (string, 'a) expr -> string -> (string, 'a) expr
373 373 val declaration_directive :
374 374 (parsing_directive * (string, parsing_directive) expr list * string ty list) label list ->
375 375 ((_ * (string, parsing_directive) expr) list as 'a) -> 'a
  376 +val declaration_directive_1 :
  377 + (parsing_directive * (string, parsing_directive) expr list * string ty list) label list ->
  378 + ((_ * (string, parsing_directive) expr) as 'a) -> 'a
376 379
377 380
378 381 (** Utils for parser_xml *)
18 opalang/js_syntax/opa_parser.trx
@@ -510,9 +510,8 @@ db_options <-
510 510 Bindings or assimilated (like do)
511 511 *)
512 512 binding_pattern <-
513   - / binding_pattern_simple
514   - / binding_pattern_lambda
515   - / binding_pattern_module
  513 + local_binding_directives:dirs (binding_pattern_simple / binding_pattern_lambda / binding_pattern_module):bnd
  514 + {{ declaration_directive_1 dirs bnd }}
516 515
517 516 binding_pattern_simple <-
518 517 'var'? spacing pattern:p assign expr:e {{ (p,e) }}
@@ -539,9 +538,8 @@ binding_pattern_simple_rec <- binding_pattern_simple:b
539 538 }}
540 539
541 540 binding_pattern_rec <-
542   - / binding_pattern_module
543   - / binding_pattern_simple_rec
544   - / binding_pattern_lambda
  541 + local_binding_directives:dirs (binding_pattern_module / binding_pattern_simple_rec / binding_pattern_lambda):bnd
  542 + {{ declaration_directive_1 dirs bnd }}
545 543
546 544 binding_ident <-
547 545 / binding_lambda
@@ -1125,10 +1123,10 @@ slicing_directive0 <-
1125 1123
1126 1124 closure_instrumentation_directive <- "public_env" {{ `public_env }}
1127 1125
1128   -local_binding_directive <- "@" (=exact_ident(slicing_directive0
1129   - /closure_instrumentation_directive)):v !"("
1130   - {{ (v, [], []) }}
1131   -local_binding_directives <- (=deco(local_binding_directive:v))*
  1126 +local_binding_directive <-
  1127 + / declaration_directive0_slicing:v {{ (v, [], []) }}
  1128 + / "@" (=exact_ident(closure_instrumentation_directive)):v !"(" {{ (v, [], []) }}
  1129 +local_binding_directives <- (=deco(local_binding_directive))*:v spacing {{ v }}
1132 1130
1133 1131 (**
1134 1132 {7 Directives}

0 comments on commit 34dba1f

Please sign in to comment.
Something went wrong with that request. Please try again.