Compare commits

...

11 commits
v0.1.1 ... main

Author SHA1 Message Date
Dominic Grimm 84f94923d2 Updated version 2021-12-27 19:40:57 +01:00
Dominic Grimm 0b7e805961 Upated return type 2021-12-27 19:40:09 +01:00
Dominic Grimm a788bdef34
Updated authors 2021-12-27 18:59:24 +01:00
Dominic Grimm 5776166876 Updated fast-sexpr link 2021-12-27 18:58:11 +01:00
Dominic Grimm 79f1f05ea8 Updated authors 2021-12-27 18:58:02 +01:00
Dominic Grimm bf7fb318a3 updated crystal version 2021-12-27 18:57:30 +01:00
Dominic Grimm a41abe8963 Updated parser class name 2021-12-27 18:57:19 +01:00
Dominic Grimm 5f8041c60f updated README 2021-10-23 16:15:23 +02:00
Dominic Grimm 1a3a7cf757 removed latest version 2021-10-20 21:00:55 +02:00
Dominic Grimm a9f9f96065 updated version 2021-10-20 20:43:07 +02:00
Dominic Grimm 46cbe8e952 added node types 2021-10-20 20:42:51 +02:00
3 changed files with 14 additions and 13 deletions

View file

@ -2,7 +2,7 @@
[![GitHub release](https://img.shields.io/github/release/grimmigerFuchs/sexpr.svg)](https://github.com/grimmigerFuchs/sexpr/releases)
A small s-expression parser based on [fast-sexpr](https://www.npmjs.com/package/fast-sexpr).
A small s-expression parser based on [fast-sexpr](https://github.com/benthepoet/fast-sexpr).
## Installation
@ -27,7 +27,9 @@ source = "
"
pp Sexpr.parse(source)
"
# [["test", ["arg1", "arg2"], "something", "else"],
# ["another", "object", ["with", ["nests", ["too"]]]]]
```
## Contributing
@ -40,4 +42,4 @@ pp Sexpr.parse(source)
## Contributors
- [grimmigerFuchs](https://github.com/grimmigerFuchs) - creator and maintainer
- [Dominic Grimm](https://github.com/grimmigerFuchs) - creator and maintainer

View file

@ -1,11 +1,10 @@
name: sexpr
description: |
A small s-expression parser based on fast-sexpr
version: 0.1.1
version: 0.1.2
authors:
- grimmigerFuchs <dominic.grimm@gmail.com>
- Dominic Grimm <dominic.grimm@gmail.com>
crystal: 1.2.0
crystal: 1.2.2
license: MIT

View file

@ -8,11 +8,11 @@ module Sexpr
alias Node = String | Body
alias Body = Array(String) | Array(Node)
private class Wrapper
class Parser
private property i = 0
private property source : String
private module Terms
module Terms
STRING = /"/
SPACE = /\s/
LIST = /(#{SPACE})|[()]/
@ -33,14 +33,14 @@ module Sexpr
private def read_value(is_terminator : Regex) : String
value = ""
while !is_terminator.matches?(strChar = get_char.to_s)
value += strChar
while !is_terminator.matches?(str_char = get_char.to_s)
value += str_char
end
value
end
private def un_get_char
private def un_get_char : Nil
@i -= 1
end
@ -70,6 +70,6 @@ module Sexpr
end
def parse(source : String) : Body
Wrapper.new(remove_comments(source)).parse
Parser.new(remove_comments(source)).parse
end
end