Created
September 22, 2020 04:59
-
-
Save sogaiu/a73aad40bd168810f16dd8b7823f1ce1 to your computer and use it in GitHub Desktop.
try out calva's clojure lexer in a repl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone https://github.com/BetterThanTomorrow/calva | |
$ cd calva | |
$ npm install -D ts-node | |
$ cd src/cursor-doc | |
$ npx ts-node | |
> import { Scanner } from './clojure-lexer' | |
{} | |
> let s = new Scanner(32768) | |
undefined | |
> s.processLine("(def a 1)") | |
[ | |
{ type: 'open', offset: 0, raw: '(', state: { inString: false } }, | |
{ type: 'id', offset: 1, raw: 'def', state: { inString: false } }, | |
{ type: 'ws', offset: 4, raw: ' ', state: { inString: false } }, | |
{ type: 'id', offset: 5, raw: 'a', state: { inString: false } }, | |
{ type: 'ws', offset: 6, raw: ' ', state: { inString: false } }, | |
{ type: 'lit', offset: 7, raw: '1', state: { inString: false } }, | |
{ type: 'close', offset: 8, raw: ')', state: { inString: false } }, | |
{ type: 'eol', raw: '\n', offset: 9, state: { inString: false } } | |
] | |
> s.processLine("#_ :a") | |
[ | |
{ type: 'ignore', offset: 0, raw: '#_', state: { inString: false } }, | |
{ type: 'ws', offset: 2, raw: ' ', state: { inString: false } }, | |
{ type: 'kw', offset: 3, raw: ':a', state: { inString: false } }, | |
{ type: 'eol', raw: '\n', offset: 5, state: { inString: false } } | |
] | |
> s.processLine("2r01") | |
[ | |
{ type: 'lit', offset: 0, raw: '2r01', state: { inString: false } }, | |
{ type: 'eol', raw: '\n', offset: 4, state: { inString: false } } | |
] | |
> s.processLine("100.0") | |
[ | |
{ type: 'lit', offset: 0, raw: '100.0', state: { inString: false } }, | |
{ type: 'eol', raw: '\n', offset: 5, state: { inString: false } } | |
] | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment