erle 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +79 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +6 -0
- data/bin/console +12 -0
- data/bin/setup +8 -0
- data/erle.gemspec +34 -0
- data/lib/erle.rb +28 -0
- data/lib/erle/elements/atom.rb +44 -0
- data/lib/erle/elements/binary.rb +31 -0
- data/lib/erle/elements/enum.rb +69 -0
- data/lib/erle/elements/list.rb +9 -0
- data/lib/erle/elements/map.rb +9 -0
- data/lib/erle/elements/numbers.rb +26 -0
- data/lib/erle/elements/pid.rb +22 -0
- data/lib/erle/elements/ref.rb +37 -0
- data/lib/erle/elements/string.rb +33 -0
- data/lib/erle/elements/term.rb +71 -0
- data/lib/erle/elements/tuple.rb +37 -0
- data/lib/erle/errors.rb +12 -0
- data/lib/erle/parser.rb +122 -0
- data/lib/erle/registry.rb +71 -0
- data/lib/erle/version.rb +3 -0
- data/spec/erle/parser/atom_spec.rb +33 -0
- data/spec/erle/parser/binary_spec.rb +19 -0
- data/spec/erle/parser/enum_spec.rb +20 -0
- data/spec/erle/parser/numbers_spec.rb +21 -0
- data/spec/erle/parser/parser_spec.rb +135 -0
- data/spec/erle/parser/pid_spec.rb +18 -0
- data/spec/erle/parser/ref_spec.rb +20 -0
- data/spec/erle/parser/term_spec.rb +20 -0
- data/spec/erle/parser/tuple_spec.rb +27 -0
- data/spec/erle/parser_spec.rb +7 -0
- data/spec/spec_helper.rb +22 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4362d71eeb6b01a8de836cf7a3720d271bfc3d7d
|
4
|
+
data.tar.gz: 2931a5d0b703b9301a4a6441c989838bbe35bbf5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1249a5c74c8120e41e855a719be44d500d351b53229fc677e84992265b4bf915239c515146f88bfc544b0b750dce0114e6b36007d1537af87d9b8770e25789f
|
7
|
+
data.tar.gz: e857539c5dad70a5ccdb69340a8f58e65af63a84f5d876b68266768d5c47646f0f6ad58d2d9332173a04994c15e472d8be295145306fe6612bd69605b40ae954
|
data/.gitignore
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Database config and secrets
|
8
|
+
/config/database.yml
|
9
|
+
/config/secrets.yml
|
10
|
+
|
11
|
+
# Ignore bundler config
|
12
|
+
/.bundle
|
13
|
+
|
14
|
+
# Ignore client credentials
|
15
|
+
/config/client_api_credentials.yml
|
16
|
+
|
17
|
+
# Ignore the default SQLite database.
|
18
|
+
/db/*.sqlite3
|
19
|
+
|
20
|
+
# Ignore all logfiles and tempfiles.
|
21
|
+
/log/*.log
|
22
|
+
/tmp
|
23
|
+
/db/structure.sql
|
24
|
+
/doc/app/*
|
25
|
+
/vendor/cldr/*
|
26
|
+
/public/uploads/*
|
27
|
+
/public/photo/*
|
28
|
+
/public/test/*
|
29
|
+
/test/assets/*
|
30
|
+
/spec/assets/*
|
31
|
+
/public/assets/**
|
32
|
+
.powenv
|
33
|
+
.rvmrc
|
34
|
+
.env
|
35
|
+
.ruby-version
|
36
|
+
.rspec_status
|
37
|
+
|
38
|
+
# Compiled source #
|
39
|
+
###################
|
40
|
+
/pkg/
|
41
|
+
*.com
|
42
|
+
*.class
|
43
|
+
*.dll
|
44
|
+
*.exe
|
45
|
+
*.o
|
46
|
+
*.so
|
47
|
+
|
48
|
+
# Packages #
|
49
|
+
############
|
50
|
+
# it's better to unpack these files and commit the raw source
|
51
|
+
# git has its own built in compression methods
|
52
|
+
*.7z
|
53
|
+
*.dmg
|
54
|
+
*.gz
|
55
|
+
*.iso
|
56
|
+
*.jar
|
57
|
+
*.rar
|
58
|
+
*.tar
|
59
|
+
*.zip
|
60
|
+
|
61
|
+
# Logs and databases #
|
62
|
+
######################
|
63
|
+
*.log
|
64
|
+
*.sql
|
65
|
+
*.sqlite
|
66
|
+
|
67
|
+
# OS generated files #
|
68
|
+
######################
|
69
|
+
.DS_Store
|
70
|
+
.DS_Store?
|
71
|
+
._*
|
72
|
+
.Spotlight-V100
|
73
|
+
.Trashes
|
74
|
+
Icon?
|
75
|
+
ehthumbs.db
|
76
|
+
Thumbs.db
|
77
|
+
/Gemfile.lock
|
78
|
+
/coverage
|
79
|
+
/.editorconfig
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dale@getnotion.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in erlang/parser.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
|
10
|
+
# Generates coverage stats of specs
|
11
|
+
gem 'simplecov'
|
12
|
+
|
13
|
+
# Publishes coverage to codeclimate
|
14
|
+
gem 'codeclimate-test-reporter'
|
15
|
+
|
16
|
+
# Gives CircleCI more perspective on our tests
|
17
|
+
gem 'rspec_junit_formatter'
|
18
|
+
|
19
|
+
gem 'rspec'
|
20
|
+
|
21
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dale Stevens
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
[![Version ](https://img.shields.io/gem/v/erlang-parser.svg?maxAge=2592000)](https://rubygems.org/gems/erlang-parser)
|
2
|
+
[![Build Status ](https://travis-ci.org/TwilightCoders/erlang-parser.svg)](https://travis-ci.org/TwilightCoders/erlang-parser)
|
3
|
+
[![Code Climate ](https://api.codeclimate.com/v1/badges/762cdcd63990efa768b0/maintainability)](https://codeclimate.com/github/TwilightCoders/erlang-parser/maintainability)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/TwilightCoders/erlang-parser/badges/coverage.svg)](https://codeclimate.com/github/TwilightCoders/erlang-parser/coverage)
|
5
|
+
[![Dependencies ](https://gemnasium.com/badges/github.com/TwilightCoders/erlang-parser.svg)](https://gemnasium.com/github.com/TwilightCoders/erlang-parser)
|
6
|
+
|
7
|
+
# ERLE::Parser
|
8
|
+
|
9
|
+
http://erlang.org/doc/reference_manual/data_types.html
|
10
|
+
|
11
|
+
Erlang Expressions are a bit different from your typical programming language. ERLE::Parser helps by parsing a string of expressions into a rich (or otherwise) data-structure for Ruby to consume.
|
12
|
+
|
13
|
+
## Requirements
|
14
|
+
Ruby 2.2+
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'erlang-parser'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install erlang-parser
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Erlang.parse(" {a,[{a_foo,'ABCDE',\"ABCDE\",<<\"ABCDE\">>}]} ")
|
36
|
+
$ {:a=>[{:a_foo=>["ABCDE", "ABCDE", "ABCDE"]}]}
|
37
|
+
```
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bundle` to install dependencies. Then, run `bundle exec rspec` to run the tests.
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/TwilightCoders/erlang-parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
46
|
+
|
47
|
+
## License
|
48
|
+
|
49
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "erle"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
12
|
+
|
data/bin/setup
ADDED
data/erle.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "erle/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "erle"
|
7
|
+
spec.version = ERLE::VERSION
|
8
|
+
spec.authors = ["Dale Stevens"]
|
9
|
+
spec.email = ["dale@twilightcoders.net"]
|
10
|
+
|
11
|
+
spec.summary = %q{Parses Erlang terms into Ruby objects}
|
12
|
+
# spec.description = %q{}
|
13
|
+
spec.homepage = "https://github.com/TwilightCoders/erlang-parser."
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
else
|
19
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0")
|
23
|
+
spec.bindir = 'bin'
|
24
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
25
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
26
|
+
spec.require_paths = ['lib', 'spec']
|
27
|
+
|
28
|
+
spec.required_ruby_version = '>= 2.1'
|
29
|
+
|
30
|
+
spec.add_development_dependency 'pry-byebug', '~> 3'
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
32
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
33
|
+
spec.add_development_dependency 'rspec', "~> 3.0"
|
34
|
+
end
|
data/lib/erle.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
require 'erle/version'
|
3
|
+
require 'erle/errors'
|
4
|
+
|
5
|
+
require 'erle/parser'
|
6
|
+
|
7
|
+
require 'erle/elements/term'
|
8
|
+
require 'erle/elements/enum'
|
9
|
+
require 'erle/elements/numbers'
|
10
|
+
require 'erle/elements/atom'
|
11
|
+
require 'erle/elements/binary'
|
12
|
+
require 'erle/elements/list'
|
13
|
+
require 'erle/elements/pid'
|
14
|
+
require 'erle/elements/ref'
|
15
|
+
require 'erle/elements/string'
|
16
|
+
require 'erle/elements/tuple'
|
17
|
+
|
18
|
+
module ERLE
|
19
|
+
|
20
|
+
def self.parse(str)
|
21
|
+
Parser.new(str).parse
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.to_ruby(str)
|
25
|
+
parse(str).to_ruby
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module ERLE
|
2
|
+
|
3
|
+
class Atom < Term
|
4
|
+
@enclosed_pattern = /[A-z0-9_@\-\.]*/
|
5
|
+
@unopened_pattern = /[a-z][A-z0-9_@]*/
|
6
|
+
|
7
|
+
@open = @close = /'/
|
8
|
+
|
9
|
+
# enclosure /'/
|
10
|
+
pattern /^'#{@enclosed_pattern.source}'/
|
11
|
+
pattern /^#{@unopened_pattern.source}/
|
12
|
+
# pattern /^[a-z][a-z0-9_@\-\.]*/ # TODO: Handle uppercase
|
13
|
+
|
14
|
+
INNER_PATTERN = /(#{@unopened_pattern}|#{@enclosed_pattern}|)/
|
15
|
+
|
16
|
+
def to_ruby
|
17
|
+
@output ||= @input
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
# An atom is a literal, a constant with name.
|
23
|
+
# An atom is to be enclosed in single quotes (')
|
24
|
+
# if it does not begin with a lower-case letter
|
25
|
+
# or if it contains other characters than
|
26
|
+
# alphanumeric characters, underscore (_), or @.
|
27
|
+
def self.parse(parser)
|
28
|
+
if (parser.scan(open))
|
29
|
+
parser.scan(@enclosed_pattern)
|
30
|
+
result = parser.matched
|
31
|
+
parser.scan(close)
|
32
|
+
elsif parser.scan(@unopened_pattern)
|
33
|
+
result = parser.matched.to_sym
|
34
|
+
else
|
35
|
+
parser.raise_unexpected_token
|
36
|
+
end
|
37
|
+
|
38
|
+
new(result)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ERLE
|
2
|
+
class Binary < Enum
|
3
|
+
enclosure /<</, />>/
|
4
|
+
@delimeter = ','
|
5
|
+
|
6
|
+
# TODO: handle specification.
|
7
|
+
# http://erlang.org/doc/reference_manual/expressions.html#bit_syntax
|
8
|
+
# Ei = Value |
|
9
|
+
# Value:Size |
|
10
|
+
# Value/TypeSpecifierList |
|
11
|
+
# Value:Size/TypeSpecifierList
|
12
|
+
|
13
|
+
def to_ruby
|
14
|
+
# using a string literal as in <<"abc">> is syntactic sugar for <<$a,$b,$c>>.
|
15
|
+
@output ||= one_or_all(terms_to_ruby)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# class BitString < Atom
|
20
|
+
# enclosure /<<\"/, /\">>/
|
21
|
+
# @delimeter = ','
|
22
|
+
|
23
|
+
# @enclosed_pattern = /[A-z0-9_@\-\.]*/
|
24
|
+
# @unopened_pattern = /[a-z][A-z0-9_@]*/
|
25
|
+
|
26
|
+
# @open = /<<\"/
|
27
|
+
# @close = /\">>/
|
28
|
+
|
29
|
+
# end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module ERLE
|
2
|
+
class Enum < Term
|
3
|
+
|
4
|
+
class << self
|
5
|
+
attr_accessor :delimeter
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :terms
|
9
|
+
|
10
|
+
@delimeter = ','
|
11
|
+
|
12
|
+
def initialize(elements)
|
13
|
+
@terms = elements.flatten(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_ruby
|
17
|
+
@output ||= terms_to_ruby
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.delimeter_regex
|
21
|
+
@delimeter_regex ||= Regexp.new(Regexp.escape(delimeter))
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.until_delimeter
|
25
|
+
@until_delimeter ||= Regexp.new("[^#{Regexp.escape(delimeter)}]*")
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse(parser)
|
29
|
+
result = []
|
30
|
+
delim = false # fake it into looking for the first value
|
31
|
+
closed = false
|
32
|
+
|
33
|
+
parser.until_done do
|
34
|
+
case
|
35
|
+
when parser.scan(close)
|
36
|
+
closed = true
|
37
|
+
parser.raise_unexpected_token("unexpected '#{delimeter}' before '#{close.source}'") if delim
|
38
|
+
break
|
39
|
+
when parser.scan(delimeter_regex)
|
40
|
+
parser.raise_unexpected_token("expected '#{delimeter}' or '#{close.source}'") if parser.match?(close)
|
41
|
+
parser.raise_unexpected_token if delim
|
42
|
+
delim = true
|
43
|
+
when !Parser::UNPARSED.equal?(value = parser.parse_value)
|
44
|
+
delim = false
|
45
|
+
result << value
|
46
|
+
else
|
47
|
+
parser.raise_unexpected_token
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
parser.raise_unexpected_token("expected '#{close.source}'") unless closed
|
52
|
+
|
53
|
+
new(result)
|
54
|
+
end
|
55
|
+
|
56
|
+
protected
|
57
|
+
|
58
|
+
def terms_to_ruby
|
59
|
+
@terms_to_ruby ||= @terms.collect do |term|
|
60
|
+
term.is_a?(Term) ? term.to_ruby : term
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def one_or_all(array)
|
65
|
+
array.length > 1 ? array : array[0]
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|