pratt_parser 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Rakefile +10 -5
- data/lib/pratt_parser.rb +11 -7
- data/pratt_parser.gemspec +2 -2
- metadata +2 -4
- data/.gitignore +0 -1
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81820fae80610bbb81b774f40c2d49cd65bff89e
|
4
|
+
data.tar.gz: fa17cb5b8dc9c818683c18c904c56fa56a679702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39390d36e34456afbfc35a0ad123967c728dabd92cbbd40d5dcf42c458ebe3c74e9bec8da1906af51c33fdd0b0fb977dd0d20139656ecddc7b182d8a4628c4ed
|
7
|
+
data.tar.gz: d15129113557a2ca01cb5c7466ba9f44c57e0b97172a0c6f470c0ed80c3ebd009af943f4cca3b9338bca5725eff7a17dd70d31139323bee229cab64e7344e0d4
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -1,14 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require "rake/clean"
|
2
2
|
|
3
3
|
task :default => :test
|
4
4
|
|
5
|
+
require "rake/testtask"
|
5
6
|
Rake::TestTask.new do |t|
|
6
7
|
t.pattern = "spec/**/*_spec.rb"
|
7
8
|
end
|
8
9
|
|
10
|
+
require "rdoc/task"
|
11
|
+
Rake::RDocTask.new do |rdoc|
|
12
|
+
rdoc.rdoc_dir = "rdoc"
|
13
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
14
|
+
end
|
15
|
+
CLEAN.include "rdoc"
|
16
|
+
|
9
17
|
task :gem do
|
10
18
|
sh "gem build pratt_parser.gemspec"
|
11
19
|
end
|
20
|
+
CLEAN.include "*.gem"
|
12
21
|
|
13
22
|
task :install => :gem do
|
14
23
|
sh "gem install pratt_parser"
|
@@ -17,7 +26,3 @@ end
|
|
17
26
|
task :push => [:clean, :gem] do
|
18
27
|
sh "gem push pratt_parser-*.gem"
|
19
28
|
end
|
20
|
-
|
21
|
-
task :clean do
|
22
|
-
sh "rm -f *.gem"
|
23
|
-
end
|
data/lib/pratt_parser.rb
CHANGED
@@ -7,17 +7,17 @@
|
|
7
7
|
#
|
8
8
|
# lexer is must have an +#each+ method that returns token objects. A token
|
9
9
|
# has three methods:
|
10
|
-
# lbp
|
10
|
+
# +lbp+::
|
11
11
|
# Returns the operator precedence. Higher numbers bind more tightly.
|
12
|
-
# nud(parser)
|
12
|
+
# <tt>nud(parser)</tt>::
|
13
13
|
# Called when the token is the first token in an expression,
|
14
14
|
# including a recursive call to +expresssion+ (i.e., subexpression).
|
15
15
|
# For example, +nud+ would be called for a unary operator, a literal,
|
16
16
|
# or for the "if" in the construct "if <cond> then <expr>". It is
|
17
17
|
# the token's responsibility to call +parser.expression+,
|
18
|
-
# +parser.expect+, and/or
|
18
|
+
# +parser.expect+, and/or +parser.if?+ to handle the remainder of the
|
19
19
|
# (sub)expression, if any.
|
20
|
-
# led(parser, left)
|
20
|
+
# <tt>led(parser, left)</tt>::
|
21
21
|
# Called when the token is preceeded by a subexpression, passed in
|
22
22
|
# as +left+. The token may be postfix or infix. It is the token's
|
23
23
|
# responsibility to call +parser.expression+, +parser.expect+,
|
@@ -30,11 +30,11 @@
|
|
30
30
|
# (sub)expression then an exception that isn't at al appropriate
|
31
31
|
# to the abstraction will be thrown.
|
32
32
|
#
|
33
|
-
# +nud+ and +led+ can call
|
33
|
+
# +nud+ and +led+ can call <tt>parser.expression(rbp)</tt> to recursively
|
34
34
|
# parse the right subexpression. +rbp+ should be the token's +lbp+ for
|
35
35
|
# left-associativity, +lbp-1+ for right.
|
36
36
|
#
|
37
|
-
#
|
37
|
+
# <tt>PrattParser.new(lexer).eval</tt> will return the result of the parse.
|
38
38
|
#
|
39
39
|
# Syntax errors aren't handled at the moment and will cause ridiculous
|
40
40
|
# exceptions to be raised such as +NoMethodError+.
|
@@ -122,8 +122,12 @@ class PrattParser
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
+
# A private class. An instance of +EndToken+ is automatically
|
126
|
+
# appended as the last token in the input stream. With its +lbp+ of
|
127
|
+
# zero it will terminate the parse.
|
128
|
+
#
|
125
129
|
class EndToken
|
126
|
-
def lbp
|
130
|
+
def lbp # :nodoc:
|
127
131
|
0
|
128
132
|
end
|
129
133
|
end
|
data/pratt_parser.gemspec
CHANGED
@@ -4,11 +4,11 @@ Gem::Specification.new do |gem|
|
|
4
4
|
gem.authors = ["Tom May"]
|
5
5
|
gem.email = ["tom@tommay.net"]
|
6
6
|
gem.homepage = "https://github.com/tommay/pratt_parser"
|
7
|
-
gem.files = `git ls-files`.split("\n")
|
7
|
+
gem.files = `git ls-files`.split("\n") - [".gitignore", ".travis.yml"]
|
8
8
|
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
9
9
|
gem.name = "pratt_parser"
|
10
10
|
gem.require_paths = ["lib"]
|
11
|
-
gem.version = "0.1.
|
11
|
+
gem.version = "0.1.2"
|
12
12
|
gem.license = "MIT"
|
13
13
|
# Needs Enumerator which was added in 1.9.
|
14
14
|
gem.required_ruby_version = ">= 1.9"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pratt_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom May
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Pratt parser. Create token objects to define your language. Create
|
14
14
|
a lexer to return tokens. Call the parser to grok the language.
|
@@ -18,8 +18,6 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- ".gitignore"
|
22
|
-
- ".travis.yml"
|
23
21
|
- CHANGELOG.md
|
24
22
|
- Gemfile
|
25
23
|
- Gemfile.lock
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
*.gem
|