mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 14:58:50 +00:00
Better dot notation
This commit is contained in:
parent
b6daf3910f
commit
5258b95712
1 changed files with 14 additions and 14 deletions
|
|
@ -635,7 +635,7 @@ module Expr =
|
|||
|
||||
primary[def][infix][atr]:
|
||||
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}
|
||||
)+
|
||||
=> {match (List.hd (List.rev is)), atr with
|
||||
|
|
@ -652,19 +652,19 @@ module Expr =
|
|||
| `Elem i -> Elem (b, i)
|
||||
| `Len -> Length 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))
|
||||
)
|
||||
b
|
||||
is
|
||||
in
|
||||
let res = match lastElem, atr with
|
||||
| `Elem i, Reff -> ElemRef (b, i)
|
||||
| `Elem i, _ -> Elem (b, i)
|
||||
| `Len, _ -> Length b
|
||||
| `Str, _ -> StringVal b
|
||||
| `Post f, _ -> Call (Var f, [b])
|
||||
| `Call args, _ -> (match b with Sexp _ -> invalid_arg "retry!" | _ -> Call (b, args))
|
||||
| `Elem i , Reff -> ElemRef (b, i)
|
||||
| `Elem i , _ -> Elem (b, i)
|
||||
| `Len , _ -> Length b
|
||||
| `Str , _ -> StringVal 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))
|
||||
in
|
||||
ignore atr res
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue