JohnEarnest / ok

An open-source interpreter for the K5 programming language.
MIT License
588 stars 72 forks source link

Support symbols that contain '.' or start with numbers #62

Closed ghost closed 8 years ago

ghost commented 8 years ago

Symbols can be any combination of letters, numbers and ".". This allows using RICs as symbols.

e.g.

KDB+ 3.1 2014.03.27 Copyright (C) 1993-2014 Kx Systems
l32/ 1()core 7670MB jordan homeserver 192.168.1.12 NONEXPIRE

Welcome to kdb+ 32bit edition
For support please see http://groups.google.com/d/forum/personal-kdbplus
Tutorials can be found at http://code.kx.com/wiki/Tutorials
To exit, type \\
To remove this startup msg, edit q.q
q)\
  `AAPL.OQ`.SPX`001.TW
`AAPL.OQ`.SPX`001.TW
  \\
JohnEarnest commented 8 years ago

oK aims for compatibility with k6, so the behavior of k3 isn't necessarily authoritative. That said, I looked into it:

> rlwrap ./k
2016.08.09 (c) arthur whitney
 `.`A.B`..`A0
`.`A.B`..`A0

 $`.`A.B`..`A0
(,".";"A.B";"..";"A0") 

 `AAPL.OQ`.SPX`001.TW
`AAPL.OQ
 `AAPL.OQ`.SPX
`AAPL.OQ`.SPX

 `0
`0
^

 `0a
`0a
^

Based on this it appears that . is indeed permitted in k6 symbols, but it is not valid to begin a symbol with a number. (Presumably 0` is parsed as 0`, ie applying the empty symbol to the number 0.) If you update your pull request to reflect this behavior I will happily merge it.

ghost commented 8 years ago

Thanks for checking. I've updated the code and documentation to match.

JohnEarnest commented 8 years ago

Perfect. Thank you!