rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
158 stars 46 forks source link

Add AstNode visitor function for createVisitor #1138

Closed markwpearce closed 4 months ago

markwpearce commented 4 months ago

Allows:

const { ast } = Parser.parse(`
    sub main()
       'comment
       print "hello"
    end sub
`);
ast.walk(createVisitor({
    CommentToken: (comment, parent, owner, key) => {
        console.log(comment.text); // prints "'comment"
    }
}), {
    walkMode: WalkMode.visitAllRecursive | WalkMode.visitComments
});
markwpearce commented 4 months ago

Fixes #1128

markwpearce commented 4 months ago

Looks great.