Better dot notation

This commit is contained in:
Dmitry Boulytchev 2019-12-21 18:04:39 +03:00
parent b6daf3910f
commit 5258b95712

View file

@ -635,7 +635,7 @@ module Expr =
primary[def][infix][atr]: primary[def][infix][atr]:
b:base[def][infix][Val] is:( "[" i:parse[def][infix][Val] "]" {`Elem i} b:base[def][infix][Val] is:( "[" i:parse[def][infix][Val] "]" {`Elem i}
| -"." (%"length" {`Len} | %"string" {`Str} | f:LIDENT {`Post f}) | -"." (%"length" {`Len} | %"string" {`Str} | f:LIDENT args:(-"(" !(Util.list)[parse def infix Val] -")")? {`Post (f, args)})
| "(" args:!(Util.list0)[parse def infix Val] ")" {`Call args} | "(" args:!(Util.list0)[parse def infix Val] ")" {`Call args}
)+ )+
=> {match (List.hd (List.rev is)), atr with => {match (List.hd (List.rev is)), atr with
@ -652,7 +652,7 @@ module Expr =
| `Elem i -> Elem (b, i) | `Elem i -> Elem (b, i)
| `Len -> Length b | `Len -> Length b
| `Str -> StringVal b | `Str -> StringVal b
| `Post f -> Call (Var f, [b]) | `Post (f, args) -> Call (Var f, b :: match args with None -> [] | Some args -> args)
| `Call args -> (match b with Sexp _ -> invalid_arg "retry!" | _ -> Call (b, args)) | `Call args -> (match b with Sexp _ -> invalid_arg "retry!" | _ -> Call (b, args))
) )
b b
@ -663,7 +663,7 @@ module Expr =
| `Elem i , _ -> Elem (b, i) | `Elem i , _ -> Elem (b, i)
| `Len , _ -> Length b | `Len , _ -> Length b
| `Str , _ -> StringVal b | `Str , _ -> StringVal b
| `Post f, _ -> Call (Var f, [b]) | `Post (f, args), _ -> Call (Var f, b :: match args with None -> [] | Some args -> args)
| `Call args , _ -> (match b with Sexp _ -> invalid_arg "retry!" | _ -> Call (b, args)) | `Call args , _ -> (match b with Sexp _ -> invalid_arg "retry!" | _ -> Call (b, args))
in in
ignore atr res ignore atr res