bel_parser 1.0.0.alpha.39-java → 1.0.0.alpha.40-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/bel_debug_ast +75 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30e9b124b70baa5376df25c5a4bb2bc4c1f71ec3
|
4
|
+
data.tar.gz: fcd4c0420366cf1be080fbd375afbd1361095545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a895fada40d46968dec3e75798f13f29e50e6910c7395368bd55df4613db6441119dc056c9ca70ada8581bb49b02d7fd331f4642bec1238048c58b79c365bf9
|
7
|
+
data.tar.gz: 9ba3b8f935d458b5ddcd91f2fe216b49a4a1aab2ad6e4869869053a49d63e1dbc0b74171d40252ed80088ece168b42060f09ecb7d5cccd42c2d13db61d297341
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.alpha.
|
1
|
+
1.0.0.alpha.40
|
data/bin/bel_debug_ast
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(
|
3
|
+
File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'bel_parser'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = <<-USAGE.gsub(/^ {4}/, '')
|
11
|
+
Debug the AST.
|
12
|
+
|
13
|
+
Read from a BEL file.
|
14
|
+
usage: #$PROGRAM_NAME --file [FILE]
|
15
|
+
|
16
|
+
Read from standard input.
|
17
|
+
usage: #$PROGRAM_NAME
|
18
|
+
USAGE
|
19
|
+
|
20
|
+
opts.on('-f', '--file FILE', 'BEL script file to read.') do |bel|
|
21
|
+
options[:file] = bel
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on('-c', '--[no-]complete', 'Output only complete AST.') do |c|
|
25
|
+
options[:complete] = c
|
26
|
+
end
|
27
|
+
end.parse!
|
28
|
+
|
29
|
+
file = options[:file]
|
30
|
+
io =
|
31
|
+
if file
|
32
|
+
File.open(file, external_encoding: 'UTF-8')
|
33
|
+
else
|
34
|
+
$stdin
|
35
|
+
end
|
36
|
+
puts options[:complete]
|
37
|
+
|
38
|
+
class ::AST::Node
|
39
|
+
|
40
|
+
def _metadata
|
41
|
+
ivars = instance_variables - [:@type, :@children, :@hash]
|
42
|
+
ivars.map { |iv| [iv, instance_variable_get(iv)] }.to_s
|
43
|
+
end
|
44
|
+
private :_metadata
|
45
|
+
|
46
|
+
def to_sexp(indent=0)
|
47
|
+
indented = " " * indent
|
48
|
+
sexp = "#{indented}(#{fancy_type} #{_metadata}"
|
49
|
+
|
50
|
+
first_node_child = children.index do |child|
|
51
|
+
child.is_a?(::AST::Node) || child.is_a?(Array)
|
52
|
+
end || children.count
|
53
|
+
|
54
|
+
children.each_with_index do |child, idx|
|
55
|
+
if child.is_a?(::AST::Node) && idx >= first_node_child
|
56
|
+
sexp << "\n#{child.to_sexp(indent + 1)}"
|
57
|
+
else
|
58
|
+
sexp << " #{child.inspect}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
sexp << ")"
|
63
|
+
|
64
|
+
sexp
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
BELParser::ASTGenerator.new(io).each do |result|
|
69
|
+
line_number, line, asts = result
|
70
|
+
puts line
|
71
|
+
asts.each do |ast|
|
72
|
+
next if options[:complete] && ast.incomplete?
|
73
|
+
puts ast.to_sexp(1)
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bel_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.40
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Anthony Bargnesi
|
@@ -42,6 +42,7 @@ dependencies:
|
|
42
42
|
description: Implements language versions 1.0 and 2.0.
|
43
43
|
email: abargnesi@selventa.com
|
44
44
|
executables:
|
45
|
+
- bel_debug_ast
|
45
46
|
- bel2_validator
|
46
47
|
- bel_script_reader
|
47
48
|
extensions: []
|
@@ -53,6 +54,7 @@ files:
|
|
53
54
|
- README.md
|
54
55
|
- VERSION
|
55
56
|
- bin/bel2_validator
|
57
|
+
- bin/bel_debug_ast
|
56
58
|
- bin/bel_script_reader
|
57
59
|
- lib/bel/translator/plugins/bel_script.rb
|
58
60
|
- lib/bel/translator/plugins/bel_script/bel_citation_serialization.rb
|