Skip to content

treequery/walk.mlua doesn't work if following the walker document #24

@wanghc78

Description

@wanghc78

If I follow the document http://metalua.luaforge.net/manual004.html#toc9 to write an ast walker, such as

  local cfg      = { expr  = { },
                      stat  = { },
                      block = { } }
  cfg.expr.down = function(x) ... end
  walk.guess(cfg, term)

The walker doesn't work. The function returned by walker_builder() in walk.mlua cannot get the correct cfg up/down functions from the input cfg.

The below changes can fix it.

208c208,209
<       local down, up = cfg.down, cfg.up

---
>       local cfgt = cfg[traverse]
>       local down, up = cfgt and cfgt.down, cfgt and cfgt.up

However, I found the current treequery.mlua will use cfg's first level methods. It seems the issue is still caused by some refactoring inconsistence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions