Compare commits

...

15 commits
v0.1.0 ... 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
Dominic Grimm 60e9d73bc8 Changed version 2021-10-19 17:28:04 +02:00
Dominic Grimm 3453bc7bab Added comment removal 2021-10-19 17:26:49 +02:00
Dominic Grimm 5c8c7dd152 Updated username 2021-10-18 19:21:57 +02:00
Dominic Grimm 68cf95a31f Updated repo url 2021-10-18 19:19:40 +02:00
3 changed files with 21 additions and 16 deletions

View file

@ -1,8 +1,8 @@
# sexpr
[![GitHub release](https://img.shields.io/github/release/grimmigerfuchs/sexpr.svg)](https://github.com/grimmigerfuchs/sexpr/releases)
[![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
@ -11,7 +11,7 @@ A small s-expression parser based on [fast-sexpr](https://www.npmjs.com/package/
```yaml
dependencies:
sexpr:
github: grimmigerfuchs/sexpr
github: grimmigerFuchs/sexpr
```
2. Run `shards install`
@ -27,12 +27,14 @@ source = "
"
pp Sexpr.parse(source)
"
# [["test", ["arg1", "arg2"], "something", "else"],
# ["another", "object", ["with", ["nests", ["too"]]]]]
```
## Contributing
1. Fork it (<https://github.com/grimmigerfuchs/sexpr/fork>)
1. Fork it (<https://github.com/grimmigerFuchs/sexpr/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
@ -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.0
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
@ -65,7 +65,11 @@ module Sexpr
end
end
def remove_comments(source : String) : String
source.gsub(/;;?.+/, nil)
end
def parse(source : String) : Body
Wrapper.new(source).parse
Parser.new(remove_comments(source)).parse
end
end