Skip to content

__copy__ implementation missing #46

@thekevinscott

Description

@thekevinscott

Hi, me again.

It looks like the dunder __copy__ methods are not carried over to Javascript:

Presumably, other dunder methods like __eq__ are not available, though I haven't checked.

In practice, this results in different outcomes when running accepts. Specifically, parser_state.state_stack grows with the previous token IDs instead of maintaining independent copies.

A fix for my specific issue here looks like this:

        const copiedParserState = new ParserState(
          this.parser_state.parse_conf,
          this.parser_state.lexer,
          [...this.parser_state.state_stack],
          [...this.parser_state.value_stack],
        )
        new_cursor = new InteractiveParser(this.parser, copiedParserState, copy(this.lexer_thread));

Which successfully maintains independent state_stack copies.

However, this wouldn't solve other outstanding references to dunder methods.

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