tp_plus 0.0.74 → 0.0.75
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/bin/tpp +0 -0
- data/lib/tp_plus/parser.rb +7 -2
- data/lib/tp_plus/scanner.rb +12 -0
- data/lib/tp_plus/version.rb +1 -1
- data/test/tp_plus/test_interpreter.rb +1 -1
- data/test/tp_plus/test_parser.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 715a2b6920c4a27cba58ad07cdef950bce8dc85b
|
4
|
+
data.tar.gz: 1d67bbde251dd3dc0c84f346b49cce19c07bcf45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83cbd62b3807e17cc20bfb6d4f426197f6d8da570628bb9e89d6e5f95b135b190b2e08283c483d3afa9f26a6d21e2e762360fd0ec6b45f93f68dc1346f6b8713
|
7
|
+
data.tar.gz: 5514468372d3b436202ac3f4a80f86fe0f0c5365408e124db71c13d03139a3b4bc70abc120b89c37cbb595f482a96d88a9399e4fb8431d86a0eedefe0b004973
|
data/README.md
CHANGED
@@ -68,6 +68,16 @@ Usage
|
|
68
68
|
|
69
69
|
See `tpp --help` for options.
|
70
70
|
|
71
|
+
Development
|
72
|
+
-----------
|
73
|
+
|
74
|
+
1. Install Ruby
|
75
|
+
2. Install git
|
76
|
+
3. Install bundler `gem install bundler`
|
77
|
+
4. Clone the repo `git clone https://github.com/onerobotics/tp_plus.git`
|
78
|
+
5. Install dependencies with `bundle`
|
79
|
+
6. Build the parser and run the tests with `rake`
|
80
|
+
|
71
81
|
License
|
72
82
|
-------
|
73
83
|
|
data/bin/tpp
CHANGED
File without changes
|
data/lib/tp_plus/parser.rb
CHANGED
@@ -31,9 +31,14 @@ module TPPlus
|
|
31
31
|
|
32
32
|
do_parse
|
33
33
|
@interpreter
|
34
|
-
rescue Racc::ParseError => e
|
35
|
-
raise "Parse error on line #{@interpreter.line_count+1}: #{e}"
|
36
34
|
end
|
35
|
+
|
36
|
+
def on_error(t, val, vstack)
|
37
|
+
raise ParseError, sprintf("Parse error on line #{@scanner.tok_line} column #{@scanner.tok_col}: %s (%s)",
|
38
|
+
val.inspect, token_to_str(t) || '?')
|
39
|
+
end
|
40
|
+
|
41
|
+
class ParseError < StandardError ; end
|
37
42
|
##### State transition tables begin ###
|
38
43
|
|
39
44
|
racc_action_table = [
|
data/lib/tp_plus/scanner.rb
CHANGED
@@ -3,13 +3,20 @@ module TPPlus
|
|
3
3
|
def initialize
|
4
4
|
end
|
5
5
|
|
6
|
+
attr_reader :lineno, :col
|
7
|
+
attr_reader :tok_line, :tok_col
|
6
8
|
def scan_setup(src)
|
7
9
|
@src = src
|
8
10
|
@lineno = 1
|
9
11
|
@ch = " "
|
10
12
|
@offset = 0
|
13
|
+
@col = 0
|
11
14
|
@rdOffset = 0
|
12
15
|
@prevDot = false # for groups
|
16
|
+
|
17
|
+
@tok_line = 0
|
18
|
+
@tok_col = 0
|
19
|
+
|
13
20
|
self.next
|
14
21
|
end
|
15
22
|
|
@@ -19,8 +26,10 @@ module TPPlus
|
|
19
26
|
@ch = @src[@rdOffset]
|
20
27
|
if @ch == "\n"
|
21
28
|
@lineno += 1
|
29
|
+
@col = 0
|
22
30
|
end
|
23
31
|
@rdOffset += 1
|
32
|
+
@col += 1
|
24
33
|
else
|
25
34
|
@offset = @src.length
|
26
35
|
@ch = -1
|
@@ -131,6 +140,9 @@ module TPPlus
|
|
131
140
|
def next_token
|
132
141
|
self.skipWhitespace
|
133
142
|
|
143
|
+
@tok_line = @lineno
|
144
|
+
@tok_col = @col
|
145
|
+
|
134
146
|
tok = nil
|
135
147
|
lit = ""
|
136
148
|
ch = @ch
|
data/lib/tp_plus/version.rb
CHANGED
data/test/tp_plus/test_parser.rb
CHANGED
@@ -493,4 +493,10 @@ end)
|
|
493
493
|
assert_equal 3, l.args.length
|
494
494
|
end
|
495
495
|
|
496
|
+
def test_parse_error_reporting
|
497
|
+
e = assert_raise(TPPlus::Parser::ParseError) do
|
498
|
+
parse("foo bar")
|
499
|
+
end
|
500
|
+
assert_equal "Parse error on line 1 column 5: \"bar\" (WORD)", e.message
|
501
|
+
end
|
496
502
|
end
|