File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,17 @@ type Throw struct {
342342func (f * Throw ) Pos () Pos { return f .Throw }
343343func (f * Throw ) Cmd () Cmd { return * f .ExArg .Cmd }
344344
345+ // vimlparser: EVAL .ea .left
346+ // :eval {Expr}
347+ type Eval struct {
348+ Eval Pos // position of starting the :eval
349+ ExArg ExArg // Ex command arg
350+ Expr Expr
351+ }
352+
353+ func (f * Eval ) Pos () Pos { return f .Eval }
354+ func (f * Eval ) Cmd () Cmd { return * f .ExArg .Cmd }
355+
345356// vimlparser: ECHO .ea .list
346357// vimlparser: ECHON .ea .list
347358// vimlparser: ECHOMSG .ea .list
@@ -584,6 +595,7 @@ func (*Let) stmtNode() {}
584595func (* LockVar ) stmtNode () {}
585596func (* Return ) stmtNode () {}
586597func (* Throw ) stmtNode () {}
598+ func (* Eval ) stmtNode () {}
587599func (* Try ) stmtNode () {}
588600func (* UnLet ) stmtNode () {}
589601func (* UnLockVar ) stmtNode () {}
Original file line number Diff line number Diff line change @@ -135,6 +135,9 @@ func Walk(v Visitor, node Node) {
135135 case * Throw :
136136 Walk (v , n .Expr )
137137
138+ case * Eval :
139+ Walk (v , n .Expr )
140+
138141 case * EchoCmd :
139142 walkExprList (v , n .Exprs )
140143
Original file line number Diff line number Diff line change @@ -129,6 +129,8 @@ func (c *Compiler) compileExcommand(node ast.ExCommand) error {
129129 c .compileTry (n )
130130 case * ast.Throw :
131131 c .compileThrow (n )
132+ case * ast.Eval :
133+ c .compileEval (n )
132134 case * ast.EchoCmd :
133135 c .compileEchocmd (n )
134136 case * ast.Echohl :
@@ -332,6 +334,11 @@ func (c *Compiler) compileThrow(node *ast.Throw) {
332334 c .fprintln ("(%s %s)" , cmd , c .compileExpr (node .Expr ))
333335}
334336
337+ func (c * Compiler ) compileEval (node * ast.Eval ) {
338+ cmd := node .Cmd ().Name
339+ c .fprintln ("(%s %s)" , cmd , c .compileExpr (node .Expr ))
340+ }
341+
335342func (c * Compiler ) compileEchocmd (node * ast.EchoCmd ) {
336343 cmd := node .Cmd ().Name
337344 exprs := make ([]string , 0 , len (node .Exprs ))
Original file line number Diff line number Diff line change @@ -277,6 +277,13 @@ func newAstNode(n *VimNode, filename string) ast.Node {
277277 Expr : newExprNode (n .left , filename ),
278278 }
279279
280+ case NODE_EVAL :
281+ return & ast.Eval {
282+ Eval : pos ,
283+ ExArg : newExArg (* n .ea , filename ),
284+ Expr : newExprNode (n .left , filename ),
285+ }
286+
280287 case NODE_ECHO , NODE_ECHON , NODE_ECHOMSG , NODE_ECHOERR :
281288 return & ast.EchoCmd {
282289 Start : pos ,
You can’t perform that action at this time.
0 commit comments