go-edn / edn

Go implementation of EDN (Extensible Data Notation)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

single quote is a valid rune for symbols and keywords

tolitius opened this issue · comments

Currently symbols and keywords that have single quotes (i.e. :info-didn't-change) will fail to parse since "'" is not a valid rune.

Since okSymbol function in lexer.go is used for more than just symbols, I am not sure where you think is best to add it.

For now I added it here: https://github.com/tolitius/go-edn/blob/v1/lexer.go#L251

That is of course if you agree that "'" is a valid rune

Yeah, this is somewhat related to edn-format/edn#67: I decided to not support it initially, but I don't mind supporting single quotes in symbols and keywords.

okSymbol is used in keywords and symbols only, so it should be fine to add single quote there: That means adding '\'' to the list of allowed characters here:

edn/lexer.go

Lines 103 to 109 in d191449

func okSymbol(r rune) bool {
switch r {
case '.', '*', '+', '!', '-', '_', '?', '$', '%', '&', '=', '<', '>', ':', '#':
return true
}
return false
}

Happy to take a patch for this, otherwise I'll likely just fix it later today.