Skip to content

RuleNode is not typed #24

@xukai92

Description

@xukai92

I'm new to this package, but I hit some performance bottleneck due to type instability. Particularly, RuleNode is not typed, so does get_executable (e.g.

root = (rulenode._val != nothing) ?
). As a result, programs that evaluate the tree under a grammar are not typed and tends to have performance issues.

By looking at

mutable struct RuleNode
ind::Int # index in grammar
_val::Any #value of _() evals
children::Vector{RuleNode}
end
, it seems to me that it should be possible to correctly type RuleNode because we can know the type of _val from a grammar - if a grammar is specificed. This is actually done in the the codes below the struct definition.

Does it make sense to support such things, either in RuleNode or another new struct (e.g. TypedRuleNode?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions