lox 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.reek.yml +4 -0
- data/.rubocop.yml +0 -7
- data/.travis.yml +13 -12
- data/CODE_OF_CONDUCT.md +14 -13
- data/Gemfile +1 -1
- data/Gemfile.lock +36 -132
- data/LICENSE.txt +1 -1
- data/README.md +23 -8
- data/Rakefile +3 -3
- data/bin/console +4 -4
- data/bin/setup +1 -2
- data/exe/lox +2 -2
- data/lib/lox.rb +8 -7
- data/lib/lox/cli.rb +9 -9
- data/lib/lox/console.rb +1 -0
- data/lib/lox/lexical_analyzer.rb +9 -9
- data/lib/lox/scanner.rb +1 -0
- data/lib/lox/version.rb +1 -1
- data/lib/lox/write.rb +21 -0
- data/lox.gemspec +21 -20
- metadata +7 -68
- data/.codeclimate.yml +0 -28
- data/.ruby-version +0 -1
- data/bin/mutant +0 -5
- data/bin/mutant-all +0 -8
- data/lib/lox/commands/write.rb +0 -23
- data/lib/lox/core_ext/string.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eee093a674788cd8852b35bd3f03ca9cd34f6b9a0c77f6de94703e35576391c4
|
4
|
+
data.tar.gz: 3c81c1ef74d84ed48de1586c0cbd99a7958f6e57515d350ce46ffa014560862e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f04f7feb7cc9c21273e2792c4727b33bf1bf97dd03c67df09b4f576bccc6116472cd32f1b7f1ddc576f16a285d30e3d84df62bf4c0e440e5bc9fff19aadc69c5
|
7
|
+
data.tar.gz: ad4f8b8b5748afe42ee3b710e587db7e3ac421e8172857ba725d0bcb59afb885ff7d629ba824ebec4130673aa89eba884fcc83e8b0894c356854a980cf90e883
|
data/.gitignore
CHANGED
data/.reek.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require: rubocop-rspec
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
DisplayCopNames: true
|
5
4
|
EnabledByDefault: true
|
6
5
|
TargetRubyVersion: 2.2
|
7
6
|
|
@@ -18,9 +17,3 @@ Style/Documentation:
|
|
18
17
|
|
19
18
|
Style/DocumentationMethod:
|
20
19
|
Enabled: false
|
21
|
-
|
22
|
-
Style/FrozenStringLiteralComment:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Style/MethodCallWithArgsParentheses:
|
26
|
-
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
1
3
|
language: ruby
|
4
|
+
cache: bundler
|
2
5
|
rvm:
|
3
|
-
- 2.5
|
4
|
-
- 2.4
|
5
|
-
- 2.3
|
6
6
|
- 2.2
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
|
15
|
-
|
7
|
+
- 2.3
|
8
|
+
- 2.4
|
9
|
+
- 2.5
|
10
|
+
before_install: gem install bundler -v 1.17.3
|
11
|
+
before_script:
|
12
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
13
|
+
- chmod +x ./cc-test-reporter
|
14
|
+
- ./cc-test-reporter before-build
|
15
|
+
after_script:
|
16
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
In the interest of fostering an open and welcoming environment, we as
|
6
6
|
contributors and maintainers pledge to making participation in our project and
|
7
7
|
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity
|
10
|
-
orientation.
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of
|
9
|
+
experience, nationality, personal appearance, race, religion, or sexual identity
|
10
|
+
and orientation.
|
11
11
|
|
12
12
|
## Our Standards
|
13
13
|
|
@@ -23,7 +23,7 @@ include:
|
|
23
23
|
Examples of unacceptable behavior by participants include:
|
24
24
|
|
25
25
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
26
|
+
advances
|
27
27
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
28
|
* Public or private harassment
|
29
29
|
* Publishing others' private information, such as a physical or electronic
|
@@ -37,11 +37,11 @@ Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
37
|
behavior and are expected to take appropriate and fair corrective action in
|
38
38
|
response to any instances of unacceptable behavior.
|
39
39
|
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or reject
|
41
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
42
|
+
not aligned to this Code of Conduct, or to ban temporarily or permanently any
|
43
|
+
contributor for other behaviors that they deem inappropriate, threatening,
|
44
|
+
offensive, or harmful.
|
45
45
|
|
46
46
|
## Scope
|
47
47
|
|
@@ -58,8 +58,9 @@ Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
58
|
reported by contacting the project team at <richard.elias.dodson@gmail.com>. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
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
|
62
|
-
Further details of specific enforcement policies may be posted
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
62
|
+
incident. Further details of specific enforcement policies may be posted
|
63
|
+
separately.
|
63
64
|
|
64
65
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
66
|
faith may face temporary or permanent repercussions as determined by other
|
@@ -67,8 +68,8 @@ members of the project's leadership.
|
|
67
68
|
|
68
69
|
## Attribution
|
69
70
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
71
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
72
|
+
version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
72
73
|
|
73
74
|
[homepage]: http://contributor-covenant.org
|
74
75
|
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,165 +1,70 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lox (0.1.
|
4
|
+
lox (0.1.1)
|
5
5
|
thor
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
ice_nine (~> 0.11.0)
|
13
|
-
memoizable (~> 0.4.0)
|
14
|
-
addressable (2.4.0)
|
15
|
-
anima (0.3.0)
|
16
|
-
abstract_type (~> 0.0.7)
|
17
|
-
adamantium (~> 0.2)
|
18
|
-
equalizer (~> 0.0.11)
|
19
|
-
ast (2.3.0)
|
20
|
-
backports (3.11.0)
|
21
|
-
byebug (9.1.0)
|
22
|
-
codeclimate-test-reporter (1.0.7)
|
23
|
-
simplecov
|
10
|
+
ast (2.4.0)
|
11
|
+
byebug (10.0.2)
|
24
12
|
coderay (1.1.2)
|
25
|
-
concord (0.1.5)
|
26
|
-
adamantium (~> 0.2.0)
|
27
|
-
equalizer (~> 0.0.9)
|
28
13
|
diff-lcs (1.3)
|
29
|
-
docile (1.1
|
30
|
-
|
31
|
-
ethon (0.11.0)
|
32
|
-
ffi (>= 1.3.0)
|
33
|
-
faraday (0.13.1)
|
34
|
-
multipart-post (>= 1.2, < 3)
|
35
|
-
faraday_middleware (0.12.2)
|
36
|
-
faraday (>= 0.7.4, < 1.0)
|
37
|
-
ffi (1.9.18)
|
38
|
-
gh (0.15.1)
|
39
|
-
addressable (~> 2.4.0)
|
40
|
-
backports
|
41
|
-
faraday (~> 0.8)
|
42
|
-
multi_json (~> 1.0)
|
43
|
-
net-http-persistent (~> 2.9)
|
44
|
-
net-http-pipeline
|
45
|
-
highline (1.7.10)
|
46
|
-
ice_nine (0.11.2)
|
14
|
+
docile (1.3.1)
|
15
|
+
jaro_winkler (1.5.1)
|
47
16
|
json (2.1.0)
|
48
|
-
|
49
|
-
addressable (~> 2.3)
|
50
|
-
memoizable (0.4.2)
|
51
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
52
|
-
method_source (0.9.0)
|
53
|
-
morpher (0.2.6)
|
54
|
-
abstract_type (~> 0.0.7)
|
55
|
-
adamantium (~> 0.2.0)
|
56
|
-
anima (~> 0.3.0)
|
57
|
-
ast (~> 2.2)
|
58
|
-
concord (~> 0.1.5)
|
59
|
-
equalizer (~> 0.0.9)
|
60
|
-
ice_nine (~> 0.11.0)
|
61
|
-
procto (~> 0.0.2)
|
62
|
-
multi_json (1.13.1)
|
63
|
-
multipart-post (2.0.0)
|
64
|
-
mutant (0.8.14)
|
65
|
-
abstract_type (~> 0.0.7)
|
66
|
-
adamantium (~> 0.2.0)
|
67
|
-
anima (~> 0.3.0)
|
68
|
-
ast (~> 2.2)
|
69
|
-
concord (~> 0.1.5)
|
70
|
-
diff-lcs (~> 1.3)
|
71
|
-
equalizer (~> 0.0.9)
|
72
|
-
ice_nine (~> 0.11.1)
|
73
|
-
memoizable (~> 0.4.2)
|
74
|
-
morpher (~> 0.2.6)
|
75
|
-
parallel (~> 1.3)
|
76
|
-
parser (>= 2.3.1.4, < 2.5)
|
77
|
-
procto (~> 0.0.2)
|
78
|
-
regexp_parser (~> 0.4.3)
|
79
|
-
unparser (~> 0.2.5)
|
80
|
-
mutant-rspec (0.8.14)
|
81
|
-
mutant (~> 0.8.14)
|
82
|
-
rspec-core (>= 3.4.0, < 3.7.0)
|
83
|
-
net-http-persistent (2.9.4)
|
84
|
-
net-http-pipeline (1.0.1)
|
17
|
+
method_source (0.9.2)
|
85
18
|
parallel (1.12.1)
|
86
|
-
parser (2.
|
87
|
-
ast (~> 2.
|
88
|
-
powerpack (0.1.
|
89
|
-
|
90
|
-
pry (0.11.3)
|
19
|
+
parser (2.5.3.0)
|
20
|
+
ast (~> 2.4.0)
|
21
|
+
powerpack (0.1.2)
|
22
|
+
pry (0.12.2)
|
91
23
|
coderay (~> 1.1.0)
|
92
24
|
method_source (~> 0.9.0)
|
93
|
-
pry-byebug (3.
|
94
|
-
byebug (~>
|
25
|
+
pry-byebug (3.6.0)
|
26
|
+
byebug (~> 10.0)
|
95
27
|
pry (~> 0.10)
|
96
|
-
pusher-client (0.6.2)
|
97
|
-
json
|
98
|
-
websocket (~> 1.0)
|
99
28
|
rainbow (3.0.0)
|
100
|
-
rake (12.3.
|
101
|
-
|
102
|
-
|
103
|
-
rspec-
|
104
|
-
rspec-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
rspec-expectations (3.6.0)
|
29
|
+
rake (12.3.2)
|
30
|
+
rspec (3.8.0)
|
31
|
+
rspec-core (~> 3.8.0)
|
32
|
+
rspec-expectations (~> 3.8.0)
|
33
|
+
rspec-mocks (~> 3.8.0)
|
34
|
+
rspec-core (3.8.0)
|
35
|
+
rspec-support (~> 3.8.0)
|
36
|
+
rspec-expectations (3.8.2)
|
109
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
110
|
-
rspec-support (~> 3.
|
111
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.8.0)
|
39
|
+
rspec-mocks (3.8.0)
|
112
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
113
|
-
rspec-support (~> 3.
|
114
|
-
rspec-support (3.
|
115
|
-
rubocop (0.
|
41
|
+
rspec-support (~> 3.8.0)
|
42
|
+
rspec-support (3.8.0)
|
43
|
+
rubocop (0.62.0)
|
44
|
+
jaro_winkler (~> 1.5.1)
|
116
45
|
parallel (~> 1.10)
|
117
|
-
parser (>= 2.
|
46
|
+
parser (>= 2.5, != 2.5.1.1)
|
118
47
|
powerpack (~> 0.1)
|
119
48
|
rainbow (>= 2.2.2, < 4.0)
|
120
49
|
ruby-progressbar (~> 1.7)
|
121
|
-
unicode-display_width (~> 1.
|
122
|
-
rubocop-rspec (1.
|
123
|
-
rubocop (>= 0.
|
124
|
-
ruby-progressbar (1.
|
125
|
-
simplecov (0.
|
126
|
-
docile (~> 1.1
|
50
|
+
unicode-display_width (~> 1.4.0)
|
51
|
+
rubocop-rspec (1.31.0)
|
52
|
+
rubocop (>= 0.60.0)
|
53
|
+
ruby-progressbar (1.10.0)
|
54
|
+
simplecov (0.16.1)
|
55
|
+
docile (~> 1.1)
|
127
56
|
json (>= 1.8, < 3)
|
128
57
|
simplecov-html (~> 0.10.0)
|
129
58
|
simplecov-html (0.10.2)
|
130
|
-
thor (0.20.
|
131
|
-
|
132
|
-
travis (1.8.8)
|
133
|
-
backports
|
134
|
-
faraday (~> 0.9)
|
135
|
-
faraday_middleware (~> 0.9, >= 0.9.1)
|
136
|
-
gh (~> 0.13)
|
137
|
-
highline (~> 1.6)
|
138
|
-
launchy (~> 2.1)
|
139
|
-
pusher-client (~> 0.4)
|
140
|
-
typhoeus (~> 0.6, >= 0.6.8)
|
141
|
-
typhoeus (0.8.0)
|
142
|
-
ethon (>= 0.8.0)
|
143
|
-
unicode-display_width (1.3.0)
|
144
|
-
unparser (0.2.6)
|
145
|
-
abstract_type (~> 0.0.7)
|
146
|
-
adamantium (~> 0.2.0)
|
147
|
-
concord (~> 0.1.5)
|
148
|
-
diff-lcs (~> 1.3)
|
149
|
-
equalizer (~> 0.0.9)
|
150
|
-
parser (>= 2.3.1.2, < 2.5)
|
151
|
-
procto (~> 0.0.2)
|
152
|
-
websocket (1.2.5)
|
59
|
+
thor (0.20.3)
|
60
|
+
unicode-display_width (1.4.1)
|
153
61
|
|
154
62
|
PLATFORMS
|
155
63
|
ruby
|
156
64
|
|
157
65
|
DEPENDENCIES
|
158
66
|
bundler
|
159
|
-
codeclimate-test-reporter
|
160
67
|
lox!
|
161
|
-
mutant
|
162
|
-
mutant-rspec
|
163
68
|
pry
|
164
69
|
pry-byebug
|
165
70
|
rake
|
@@ -167,7 +72,6 @@ DEPENDENCIES
|
|
167
72
|
rubocop
|
168
73
|
rubocop-rspec
|
169
74
|
simplecov
|
170
|
-
travis
|
171
75
|
|
172
76
|
BUNDLED WITH
|
173
|
-
1.
|
77
|
+
1.17.3
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017-
|
3
|
+
Copyright (c) 2017-2019 Richard E. Dodson
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# Lox
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/lox.svg)](https://badge.fury.io/rb/lox)
|
3
4
|
[![Build Status](https://travis-ci.org/rdodson41/ruby-lox.svg?branch=master)](https://travis-ci.org/rdodson41/ruby-lox)
|
4
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/827f986f775a6dbfc4e6/maintainability)](https://codeclimate.com/github/rdodson41/ruby-lox/maintainability)
|
5
6
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/827f986f775a6dbfc4e6/test_coverage)](https://codeclimate.com/github/rdodson41/ruby-lox/test_coverage)
|
6
7
|
|
7
|
-
The `lox` gem is an implementation of the
|
8
|
+
The `lox` gem is an implementation of the
|
9
|
+
[Lox Language](https://github.com/munificent/craftinginterpreters/wiki/Lox-implementations)
|
10
|
+
which is written in Ruby.
|
8
11
|
|
9
12
|
## Installation
|
10
13
|
|
@@ -16,26 +19,38 @@ gem 'lox'
|
|
16
19
|
|
17
20
|
And then execute:
|
18
21
|
|
19
|
-
|
22
|
+
bundle install
|
20
23
|
|
21
24
|
Or install it yourself as:
|
22
25
|
|
23
|
-
|
26
|
+
gem install lox
|
24
27
|
|
25
28
|
## Development
|
26
29
|
|
27
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
31
|
+
`bundle exec rake spec` to run the tests. You can also run `bin/console` for an
|
32
|
+
interactive prompt that will allow you to experiment.
|
28
33
|
|
29
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
35
|
+
release a new version, update the version number in `lib/lox/version.rb`, and
|
36
|
+
then run `bundle exec rake release`, which will create a git tag for the
|
37
|
+
version, push git commits and tags, and push the `.gem` file to
|
38
|
+
[rubygems.org](https://rubygems.org).
|
30
39
|
|
31
40
|
## Contributing
|
32
41
|
|
33
|
-
Bug reports and pull requests are welcome on GitHub at
|
42
|
+
Bug reports and pull requests are welcome on GitHub at
|
43
|
+
<https://github.com/rdodson41/ruby-lox>. This project is intended to be a safe,
|
44
|
+
welcoming space for collaboration, and contributors are expected to adhere to
|
45
|
+
the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
34
46
|
|
35
47
|
## License
|
36
48
|
|
37
|
-
The gem is available as open source under the terms of the
|
49
|
+
The gem is available as open source under the terms of the
|
50
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
38
51
|
|
39
52
|
## Code of Conduct
|
40
53
|
|
41
|
-
Everyone interacting in the Lox project’s codebases, issue trackers, chat rooms
|
54
|
+
Everyone interacting in the Lox project’s codebases, issue trackers, chat rooms
|
55
|
+
and mailing lists is expected to follow the
|
56
|
+
[code of conduct](https://github.com/rdodson41/ruby-lox/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require('bundler/setup')
|
4
|
+
require('lox')
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
require
|
10
|
+
require('pry')
|
11
11
|
Pry.start
|
12
12
|
|
13
|
-
# require
|
13
|
+
# require('irb')
|
14
14
|
# IRB.start(__FILE__)
|
data/bin/setup
CHANGED
data/exe/lox
CHANGED
data/lib/lox.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require('lox/cli')
|
2
|
+
require('lox/console')
|
3
|
+
require('lox/formatter')
|
4
|
+
require('lox/lexical_analyzer')
|
5
|
+
require('lox/scanner')
|
6
|
+
require('lox/version')
|
7
|
+
require('lox/write')
|
8
8
|
|
9
9
|
module Lox
|
10
|
+
class Error < StandardError; end
|
10
11
|
# Your code goes here...
|
11
12
|
end
|
data/lib/lox/cli.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require('lox/console')
|
2
|
+
require('lox/formatter')
|
3
|
+
require('lox/lexical_analyzer')
|
4
|
+
require('lox/scanner')
|
5
|
+
require('lox/write')
|
6
|
+
require('thor')
|
7
7
|
|
8
8
|
module Lox
|
9
9
|
class CLI < Thor
|
10
10
|
desc 'read', 'Read input from the console and ' \
|
11
11
|
'write lines to standard output'
|
12
12
|
def read
|
13
|
-
|
13
|
+
Write.new(lines, STDOUT).call
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'scan', 'Scan input from the console and ' \
|
17
17
|
'write characters to standard output'
|
18
18
|
def scan
|
19
|
-
|
19
|
+
Write.new(characters, STDOUT).call
|
20
20
|
end
|
21
21
|
|
22
22
|
desc 'lex', 'Perform lexical analysis of input from the console and ' \
|
23
23
|
'write tokens to standard output'
|
24
24
|
def lex
|
25
|
-
|
25
|
+
Write.new(tokens, STDOUT).call
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
data/lib/lox/console.rb
CHANGED
data/lib/lox/lexical_analyzer.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require 'lox/lexical_analyzer/unterminated_string'
|
1
|
+
require('lox/lexical_analyzer/invalid_character')
|
2
|
+
require('lox/lexical_analyzer/invalid_state')
|
3
|
+
require('lox/lexical_analyzer/unterminated_string')
|
5
4
|
|
6
5
|
module Lox
|
7
6
|
class LexicalAnalyzer
|
@@ -13,6 +12,7 @@ module Lox
|
|
13
12
|
|
14
13
|
def each_token(&block)
|
15
14
|
return enum_for(:each_token) unless block_given?
|
15
|
+
|
16
16
|
state = :default
|
17
17
|
lexeme = nil
|
18
18
|
input.each_char do |character|
|
@@ -48,7 +48,7 @@ module Lox
|
|
48
48
|
# rubocop:enable Metrics/MethodLength
|
49
49
|
|
50
50
|
def comment(_lexeme, character)
|
51
|
-
if character
|
51
|
+
if character =~ /./
|
52
52
|
:comment
|
53
53
|
else
|
54
54
|
:default
|
@@ -56,7 +56,7 @@ module Lox
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def integer(lexeme, character, &block)
|
59
|
-
if character
|
59
|
+
if character =~ /\d/
|
60
60
|
[:integer, lexeme + character]
|
61
61
|
else
|
62
62
|
yield([:integer, Integer(lexeme)])
|
@@ -65,7 +65,7 @@ module Lox
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def string(lexeme, character)
|
68
|
-
if character
|
68
|
+
if character =~ /["]/
|
69
69
|
yield([:string, lexeme[1..-1]])
|
70
70
|
:default
|
71
71
|
else
|
@@ -74,7 +74,7 @@ module Lox
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def identifier(lexeme, character, &block)
|
77
|
-
if character
|
77
|
+
if character =~ /\w/
|
78
78
|
[:identifier, lexeme + character]
|
79
79
|
else
|
80
80
|
yield([:identifier, lexeme])
|
@@ -83,7 +83,7 @@ module Lox
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def operator(lexeme, character, &block)
|
86
|
-
if character
|
86
|
+
if character =~ /[=]/
|
87
87
|
yield([lexeme + character])
|
88
88
|
:default
|
89
89
|
else
|
data/lib/lox/scanner.rb
CHANGED
data/lib/lox/version.rb
CHANGED
data/lib/lox/write.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Lox
|
2
|
+
class Write
|
3
|
+
attr_reader :objects
|
4
|
+
attr_reader :output
|
5
|
+
|
6
|
+
def initialize(objects, output)
|
7
|
+
@objects = objects
|
8
|
+
@output = output
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
objects.each(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def block
|
18
|
+
output.public_method(:puts)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lox.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
lib = File.expand_path('
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
3
|
+
require('lox/version')
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'lox'
|
@@ -8,33 +8,34 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['Richard E. Dodson']
|
9
9
|
spec.email = ['richard.elias.dodson@gmail.com']
|
10
10
|
|
11
|
-
spec.summary = 'An implementation of the Lox Language ' \
|
12
|
-
'
|
11
|
+
spec.summary = 'An implementation of the Lox Language which is ' \
|
12
|
+
'written in Ruby.'
|
13
13
|
spec.homepage = 'https://github.com/rdodson41/ruby-lox'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
18
|
+
# into git.
|
16
19
|
spec.files =
|
17
|
-
|
18
|
-
|
20
|
+
Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
22
|
+
f.match(%r{^(test|spec|features)/})
|
23
|
+
end
|
19
24
|
end
|
20
25
|
spec.bindir = 'exe'
|
21
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
27
|
spec.require_paths = ['lib']
|
23
28
|
|
24
|
-
spec.add_dependency
|
29
|
+
spec.add_dependency('thor')
|
25
30
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency 'rubocop'
|
35
|
-
spec.add_development_dependency 'rubocop-rspec'
|
36
|
-
spec.add_development_dependency 'simplecov'
|
37
|
-
spec.add_development_dependency 'travis'
|
31
|
+
spec.add_development_dependency('bundler')
|
32
|
+
spec.add_development_dependency('pry')
|
33
|
+
spec.add_development_dependency('pry-byebug')
|
34
|
+
spec.add_development_dependency('rake')
|
35
|
+
spec.add_development_dependency('rspec')
|
36
|
+
spec.add_development_dependency('rubocop')
|
37
|
+
spec.add_development_dependency('rubocop-rspec')
|
38
|
+
spec.add_development_dependency('simplecov')
|
38
39
|
|
39
|
-
spec.required_ruby_version = '
|
40
|
+
spec.required_ruby_version = '>= 2.2.0'
|
40
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard E. Dodson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,48 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: codeclimate-test-reporter
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: mutant
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: mutant-rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
41
|
- !ruby/object:Gem::Dependency
|
84
42
|
name: pry
|
85
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,20 +136,6 @@ dependencies:
|
|
178
136
|
- - ">="
|
179
137
|
- !ruby/object:Gem::Version
|
180
138
|
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: travis
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
139
|
description:
|
196
140
|
email:
|
197
141
|
- richard.elias.dodson@gmail.com
|
@@ -200,11 +144,10 @@ executables:
|
|
200
144
|
extensions: []
|
201
145
|
extra_rdoc_files: []
|
202
146
|
files:
|
203
|
-
- ".codeclimate.yml"
|
204
147
|
- ".gitignore"
|
148
|
+
- ".reek.yml"
|
205
149
|
- ".rspec"
|
206
150
|
- ".rubocop.yml"
|
207
|
-
- ".ruby-version"
|
208
151
|
- ".simplecov"
|
209
152
|
- ".travis.yml"
|
210
153
|
- CODE_OF_CONDUCT.md
|
@@ -214,15 +157,11 @@ files:
|
|
214
157
|
- README.md
|
215
158
|
- Rakefile
|
216
159
|
- bin/console
|
217
|
-
- bin/mutant
|
218
|
-
- bin/mutant-all
|
219
160
|
- bin/setup
|
220
161
|
- exe/lox
|
221
162
|
- lib/lox.rb
|
222
163
|
- lib/lox/cli.rb
|
223
|
-
- lib/lox/commands/write.rb
|
224
164
|
- lib/lox/console.rb
|
225
|
-
- lib/lox/core_ext/string.rb
|
226
165
|
- lib/lox/formatter.rb
|
227
166
|
- lib/lox/lexical_analyzer.rb
|
228
167
|
- lib/lox/lexical_analyzer/invalid_character.rb
|
@@ -230,6 +169,7 @@ files:
|
|
230
169
|
- lib/lox/lexical_analyzer/unterminated_string.rb
|
231
170
|
- lib/lox/scanner.rb
|
232
171
|
- lib/lox/version.rb
|
172
|
+
- lib/lox/write.rb
|
233
173
|
- lox.gemspec
|
234
174
|
homepage: https://github.com/rdodson41/ruby-lox
|
235
175
|
licenses:
|
@@ -241,17 +181,16 @@ require_paths:
|
|
241
181
|
- lib
|
242
182
|
required_ruby_version: !ruby/object:Gem::Requirement
|
243
183
|
requirements:
|
244
|
-
- - "
|
184
|
+
- - ">="
|
245
185
|
- !ruby/object:Gem::Version
|
246
|
-
version:
|
186
|
+
version: 2.2.0
|
247
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
188
|
requirements:
|
249
189
|
- - ">="
|
250
190
|
- !ruby/object:Gem::Version
|
251
191
|
version: '0'
|
252
192
|
requirements: []
|
253
|
-
|
254
|
-
rubygems_version: 2.7.3
|
193
|
+
rubygems_version: 3.0.1
|
255
194
|
signing_key:
|
256
195
|
specification_version: 4
|
257
196
|
summary: An implementation of the Lox Language which is written in Ruby.
|
data/.codeclimate.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
---
|
2
|
-
engines:
|
3
|
-
bundler-audit:
|
4
|
-
enabled: true
|
5
|
-
duplication:
|
6
|
-
enabled: true
|
7
|
-
config:
|
8
|
-
languages:
|
9
|
-
- ruby
|
10
|
-
- javascript
|
11
|
-
- python
|
12
|
-
- php
|
13
|
-
fixme:
|
14
|
-
enabled: true
|
15
|
-
rubocop:
|
16
|
-
enabled: true
|
17
|
-
ratings:
|
18
|
-
paths:
|
19
|
-
- Gemfile.lock
|
20
|
-
- "**.inc"
|
21
|
-
- "**.js"
|
22
|
-
- "**.jsx"
|
23
|
-
- "**.module"
|
24
|
-
- "**.php"
|
25
|
-
- "**.py"
|
26
|
-
- "**.rb"
|
27
|
-
exclude_paths:
|
28
|
-
- spec/
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby-2.5.0
|
data/bin/mutant
DELETED
data/bin/mutant-all
DELETED
data/lib/lox/commands/write.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Lox
|
2
|
-
module Commands
|
3
|
-
class Write
|
4
|
-
attr_reader :objects
|
5
|
-
attr_reader :output
|
6
|
-
|
7
|
-
def initialize(objects, output)
|
8
|
-
@objects = objects
|
9
|
-
@output = output
|
10
|
-
end
|
11
|
-
|
12
|
-
def call
|
13
|
-
objects.each(&writer)
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def writer
|
19
|
-
output.public_method(:puts)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|