fbtok 0.3.0 → 0.3.1

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
  SHA256:
3
- metadata.gz: db7e5c105200820cbce7e9701ed2b8ce0506e366f4215a013288b66b625528ff
4
- data.tar.gz: 3f02e52b461d14d014a3a4c3283dd452f0ca6316048969b5cf0af1cd4bd457b8
3
+ metadata.gz: c719bbab25c068f69c9bd0bc44036ad355c8ca486ea3dfbec6d2276b4d436fbb
4
+ data.tar.gz: 7053879da0e31078524b8b74453d5e7f2d3b97b0d503629467210088d91955c5
5
5
  SHA512:
6
- metadata.gz: e8c77935b70909ac04697276af902f0597f6eed411b8bddee77248a0145c1fb704eb58a59cd49744ac7e93da97fa5410ca5a35825ea3ec4ca0ea4f834d30543f
7
- data.tar.gz: 35ef329be9dddaaf94658252e9e2684b4f3f63a89da8484db3507ab36f8afefc319d2ab4f3154389539a7ad6545779dd39e710f0eb7e82990988690cea107458
6
+ metadata.gz: 38bd241c9466046377aef3c951de74b25f9a7ae1d38e1827997ba673bea7cb60105344c7f78bd997b8e0e16dc90c89946fe08db39bb3433751e1a55167e55bbf
7
+ data.tar.gz: d59f2b6fed95ebb4e7539baf4e841db5ea008b29357438de13bf3094a3062aae7e47d5825d6f7a8299a1684b3295b9c5821806eee890b67fd68dcbb392034a1e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.3.0
1
+ ### 0.3.1
2
2
  ### 0.0.1 / 2025-01-02
3
3
 
4
4
  * Everything is new. First release.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'hoe'
2
2
 
3
3
 
4
4
  Hoe.spec 'fbtok' do
5
- self.version = '0.3.0'
5
+ self.version = '0.3.1'
6
6
 
7
7
  self.summary = "fbtok - football.txt lint tools incl. tokenizer, parser & more"
8
8
  self.description = summary
@@ -21,7 +21,7 @@ Hoe.spec 'fbtok' do
21
21
  self.extra_deps = [
22
22
  # ['sportdb-structs', '>= 0.5.0'],
23
23
  # ['logutils', '>= 0.6.1'],
24
- ['sportdb-parser', '>= 0.5.4'],
24
+ ['sportdb-parser', '>= 0.5.8'],
25
25
  ['sportdb-formats', '>= 2.1.2'],
26
26
  ]
27
27
 
data/bin/fbtok CHANGED
@@ -87,7 +87,9 @@ specs.each_with_index do |spec,i|
87
87
 
88
88
  paths.each_with_index do |path,j|
89
89
  puts "==> [#{i+1}/#{specs.size}, #{j+1}/#{paths.size}] reading >#{path}<..."
90
- linter.read( path, parse: false ) ## only tokenize (do NOT parse)
90
+ tokens = linter.read( path, parse: false ) ## only tokenize (do NOT parse)
91
+
92
+ puts " #{tokens.size} token(s)"
91
93
 
92
94
  errors += linter.errors if linter.errors?
93
95
  end
data/lib/fbtok/linter.rb CHANGED
@@ -16,43 +16,49 @@ attr_reader :errors
16
16
 
17
17
  def initialize
18
18
  @errors = []
19
- @parser = Parser.new ## use own parser instance (not shared) - why? why not?
20
19
  end
21
20
 
22
21
 
23
22
  def errors?() @errors.size > 0; end
24
23
 
25
24
 
25
+
26
26
  #########
27
27
  ## parse - false (default) - tokenize (only)
28
28
  ## - true - tokenize & parse
29
29
  def read( path, parse: true )
30
30
  ## note: every (new) read call - resets errors list to empty
31
31
  @errors = []
32
-
33
- @tree = []
32
+ @tree = []
34
33
 
35
34
  outline = QuickMatchOutline.read( path )
36
35
 
37
36
  outline.each_para do |lines|
38
-
39
- if parse
37
+
40
38
  ## flatten lines (array of strings) into all-in-one string
41
39
  txt = lines.reduce( String.new ) do |mem, line|
42
- mem << line
43
- mem << "\n"
44
- mem
45
- end
46
-
40
+ mem << line
41
+ mem << "\n"
42
+ mem
43
+ end
44
+
45
+ if parse
47
46
  if debug?
48
47
  puts "lines:"
49
48
  pp txt
50
49
  end
51
50
 
52
- ## todo/fix - add/track parse errors!!!!!!
53
51
  ## pass along debug flag to parser (& tokenizer)?
54
52
  parser = RaccMatchParser.new( txt ) ## use own parser instance (not shared) - why? why not?
55
- tree = parser.parse
53
+ tree, errors = parser.parse_with_errors
54
+
55
+ if errors.size > 0
56
+ ## add to "global" error list
57
+ ## make a triplet tuple (file / msg / line text)
58
+ errors.each do |msg|
59
+ @errors << [path, msg]
60
+ end
61
+ end
56
62
 
57
63
  if debug?
58
64
  puts "parse tree:"
@@ -62,32 +68,43 @@ def read( path, parse: true )
62
68
  @tree += tree ## add nodes
63
69
 
64
70
  else ## process for tokenize only
65
- lines.each_with_index do |line,i|
66
71
 
67
72
  if debug?
68
- puts
69
- puts "line >#{line}<"
73
+ puts "lines:"
74
+ pp txt
70
75
  end
71
76
 
72
- t, error_messages = @parser.tokenize_with_errors( line )
77
+ ##
78
+ ## add (bakc) a line-by-line tracing (debug) option - why? why not?
79
+ ## now debug output is by section (not line-by-line)
80
+
81
+ lexer = Lexer.new( txt )
82
+ t, errors = lexer.tokenize_with_errors
73
83
 
74
- if error_messages.size > 0
84
+ if errors.size > 0
75
85
  ## add to "global" error list
76
86
  ## make a triplet tuple (file / msg / line text)
77
- error_messages.each do |msg|
78
- @errors << [ path,
79
- msg,
80
- line
81
- ]
87
+ errors.each do |msg|
88
+ @errors << [path, msg]
82
89
  end
83
90
  end
84
91
 
85
- pp t if debug?
86
- end # each line
92
+ if debug?
93
+ puts "tokens:"
94
+ pp t
95
+ end
96
+
97
+ @tree += t ## add tokens to "tree"
87
98
  end # parse? (or tokenize?)
88
99
  end # each para (node)
89
100
 
90
- ## note - only returns pare tree for now; no tokens (on parse=false)
101
+
102
+ ##
103
+ ## auto-add error if no tokens/tree nodes
104
+ if @tree.empty? ## @tree.size == 0
105
+ @errors << [path, "empty; no #{parse ? 'parse tree nodes' : 'tokens'}"]
106
+ end
107
+
91
108
  @tree ## return parse tree
92
109
  end # method read
93
110
  end # class Linter
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbtok
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-23 00:00:00.000000000 Z
11
+ date: 2025-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-parser
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.4
19
+ version: 0.5.8
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.4
26
+ version: 0.5.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sportdb-formats
29
29
  requirement: !ruby/object:Gem::Requirement