Skip to content

tm-go: avoid collision of token names for character literals; error: '|' and 'or' get the same ID in generated code #31

@mewmew

Description

@mewmew

I tried running the latest version of Textmapper today (the Go version at rev 9261aa2).

Doing so, I received the following error for the grammar ll.tm:

u@x1 ~/D/g/s/g/l/ll2> ~/goget/bin/textmapper generate ll.tm 
ll.tm:576:1: '|' and 'or' get the same ID in generated code

This is because the LLVM IR grammar contains both | and or as two distinct keywords/tokens.

Edit: My suggestion would be to use token.Pipe for |, however, I also realize that a more general solution may be required.

Edit2: @inspirer, any idea what the right approach would be to resolve this?

I update to Textmapper rev cd73b6b today and the issue is still present.

$ textmapper generate ll.tm
ll.tm:582:1: '|' and 'or' get the same ID in generated code

Would it make sense to add a prefix to these generated token IDs to avoid collision? E.g. | -> Character_Or (or Character_Pipe)?

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