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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 145a37ef7d63642c1a654a9e804c0dc8ce21f1b0
4
- data.tar.gz: 3229bc8c6be259a54326b1d83ff5cc295a443b6c
3
+ metadata.gz: 715a2b6920c4a27cba58ad07cdef950bce8dc85b
4
+ data.tar.gz: 1d67bbde251dd3dc0c84f346b49cce19c07bcf45
5
5
  SHA512:
6
- metadata.gz: 33068559319eff301cd865cef17e9db384ab30b50b7f59fa44659b4ba4ad87289a195ac500ce9105a7355a5561e9f483f6c9b22946c59e89458d5b85c395df9b
7
- data.tar.gz: 0c4db71fa16f12d8fa0d244c0a1b59a25a492f9911049a3697c8fa33a5b46ee6387848928dcf0daaa8ce912b461d589e353c5214d4255f0ca2eec29f3a32a2cf
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
@@ -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 = [
@@ -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
@@ -1,3 +1,3 @@
1
1
  module TPPlus
2
- VERSION = '0.0.74'
2
+ VERSION = '0.0.75'
3
3
  end
@@ -698,7 +698,7 @@ Foo::Bar::baz = 2)
698
698
 
699
699
 
700
700
  def test_bad_environment
701
- assert_raise(RuntimeError) do
701
+ assert_raise(TPPlus::Parser::ParseError) do
702
702
  @interpreter.load_environment("asdf")
703
703
  end
704
704
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tp_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.74
4
+ version: 0.0.75
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Strybis