mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 23:08:46 +00:00
Better dot notation
This commit is contained in:
parent
b6daf3910f
commit
5258b95712
1 changed files with 14 additions and 14 deletions
|
|
@ -634,9 +634,9 @@ module Expr =
|
||||||
basic[def][infix][atr]: !(expr (fun x -> x) (Array.map (fun (a, (atr, l)) -> a, (atr, List.map (fun (s, _, f) -> ostap (- $(s)), f) l)) infix) (primary def infix) atr);
|
basic[def][infix][atr]: !(expr (fun x -> x) (Array.map (fun (a, (atr, l)) -> a, (atr, List.map (fun (s, _, f) -> ostap (- $(s)), f) l)) infix) (primary def infix) atr);
|
||||||
|
|
||||||
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
|
||||||
| `Elem i, Reff -> true
|
| `Elem i, Reff -> true
|
||||||
|
|
@ -649,22 +649,22 @@ module Expr =
|
||||||
List.fold_left
|
List.fold_left
|
||||||
(fun b ->
|
(fun b ->
|
||||||
function
|
function
|
||||||
| `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
|
||||||
is
|
is
|
||||||
in
|
in
|
||||||
let res = match lastElem, atr with
|
let res = match lastElem, atr with
|
||||||
| `Elem i, Reff -> ElemRef (b, i)
|
| `Elem i , Reff -> ElemRef (b, i)
|
||||||
| `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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue