antlr4-runtime 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +37 -19
  4. data/antlr4-runtime.gemspec +1 -2
  5. data/lib/antlr4/runtime.rb +139 -19
  6. data/lib/antlr4/runtime/abstract_predicate_transition.rb +1 -3
  7. data/lib/antlr4/runtime/array_2d_hash_set.rb +1 -4
  8. data/lib/antlr4/runtime/atn.rb +1 -3
  9. data/lib/antlr4/runtime/atn_config.rb +1 -1
  10. data/lib/antlr4/runtime/atn_config_set.rb +1 -4
  11. data/lib/antlr4/runtime/atn_deserializer.rb +1 -35
  12. data/lib/antlr4/runtime/atn_simulator.rb +1 -3
  13. data/lib/antlr4/runtime/base_error_listener.rb +1 -3
  14. data/lib/antlr4/runtime/block_start_state.rb +1 -3
  15. data/lib/antlr4/runtime/buffered_token_stream.rb +1 -4
  16. data/lib/antlr4/runtime/char_stream.rb +1 -3
  17. data/lib/antlr4/runtime/char_streams.rb +1 -3
  18. data/lib/antlr4/runtime/common_token_factory.rb +1 -3
  19. data/lib/antlr4/runtime/common_token_stream.rb +1 -3
  20. data/lib/antlr4/runtime/console_error_listener.rb +1 -3
  21. data/lib/antlr4/runtime/decision_state.rb +1 -3
  22. data/lib/antlr4/runtime/default_error_strategy.rb +2 -6
  23. data/lib/antlr4/runtime/dfa.rb +1 -4
  24. data/lib/antlr4/runtime/dfa_state.rb +1 -3
  25. data/lib/antlr4/runtime/empty_prediction_context.rb +1 -2
  26. data/lib/antlr4/runtime/input_mismatch_exception.rb +1 -3
  27. data/lib/antlr4/runtime/lexer.rb +1 -6
  28. data/lib/antlr4/runtime/lexer_action_executor.rb +1 -3
  29. data/lib/antlr4/runtime/lexer_atn_config.rb +11 -4
  30. data/lib/antlr4/runtime/lexer_atn_simulator.rb +2 -7
  31. data/lib/antlr4/runtime/lexer_custom_action.rb +2 -2
  32. data/lib/antlr4/runtime/lexer_skip_action.rb +1 -3
  33. data/lib/antlr4/runtime/ll1_analyzer.rb +1 -7
  34. data/lib/antlr4/runtime/parse_tree.rb +1 -3
  35. data/lib/antlr4/runtime/parser.rb +1 -6
  36. data/lib/antlr4/runtime/parser_atn_simulator.rb +1 -5
  37. data/lib/antlr4/runtime/parser_rule_context.rb +1 -3
  38. data/lib/antlr4/runtime/predicate_transition.rb +1 -1
  39. data/lib/antlr4/runtime/prediction_context.rb +1 -3
  40. data/lib/antlr4/runtime/prediction_context_cache.rb +1 -3
  41. data/lib/antlr4/runtime/prediction_context_utils.rb +1 -4
  42. data/lib/antlr4/runtime/prediction_mode.rb +1 -4
  43. data/lib/antlr4/runtime/recognizer.rb +1 -4
  44. data/lib/antlr4/runtime/rule_context.rb +1 -3
  45. data/lib/antlr4/runtime/rule_node.rb +1 -3
  46. data/lib/antlr4/runtime/singleton_prediction_context.rb +1 -4
  47. data/lib/antlr4/runtime/syntax_tree.rb +1 -3
  48. data/lib/antlr4/runtime/token.rb +1 -2
  49. data/lib/antlr4/runtime/tokens_start_state.rb +1 -3
  50. data/lib/antlr4/runtime/version.rb +1 -1
  51. data/lib/antlr4/runtime/vocabulary_impl.rb +1 -3
  52. data/lib/antlr4/runtime/writable_token.rb +1 -3
  53. metadata +2 -17
  54. data/Gemfile.lock +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a03191431e6a6af1722e62768fce62dd24efd4fc2d01f6b42770eea00bb3bdb
4
- data.tar.gz: ae5d2ac9cbc8d52a318d5356ea57c3cdfe3c9cc581051ad4da889d84cb106ce3
3
+ metadata.gz: 005aca7d83ae7448f260d9d41c7f12c8f18ae4f4a5c95ae9b1140f2b3f70e6ee
4
+ data.tar.gz: 2a067a0a0a10437f2afbde8b7418e031c8af0eca88542bf696b1ada31c7f47a2
5
5
  SHA512:
6
- metadata.gz: 59f76c79be742eb8bf80106080810b52c07cffac4a2664dfa92d6ebecc402478e5763cadb257f5f3ef9e39febc52d39119fa4c982f48c671881b654354d9ae0b
7
- data.tar.gz: 8666a5d04f86cf9402b8042b4099969391201eb0587fead324035c41eb7d34457bf7d53891908450425b277a97e53d09f2fd6022315437060dda796c99f3df4c
6
+ metadata.gz: 7860511d158e5b19a9eae7d74e402e12c4e73a4024d6258290abdf8e26509d23a3bc2ad8dcc5ca5ae3031acec403f2904654567bbea67f9645854caac69ff378
7
+ data.tar.gz: '04095f65b57d2a01d91e2f6b1886d840b3f6323a4d0b84c6c5f9689604fc9083b136325946428591aabab7b1a85dcf8eceebc1a07463e3a4005f696e77cafd79'
data/.gitignore CHANGED
@@ -10,6 +10,8 @@
10
10
  .idea
11
11
  **/*.bundle
12
12
  **/*.o
13
+ Gemfile.lock
14
+ .ruby-version
13
15
 
14
16
  # rspec failure tracking
15
17
  .rspec_status
data/README.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  This gem adds support for the ANTLR4 runtime for Ruby lexers and parsers generated from the Ruby langauge
4
4
  target available at https://github.com/twalmsley/antlr4/tree/ruby_dev
5
+ ## Generate Your Ruby ANTLR4 Grammar
6
+
7
+ In a clean directory:
8
+
9
+ ```
10
+ $ git clone git@github.com:twalmsley/antlr4.git
11
+ $ cd antlr4
12
+ $ git checkout ruby_dev
13
+ $ export MAVEN_OPTS="-Xmx1G"
14
+ $ mvn clean
15
+ $ mvn -DskipTests install
16
+ $ cd <my-grammar-directory>
17
+ $ java -jar ~/.m2/repository/org/antlr/antlr4/4.7.3-SNAPSHOT/antlr4-4.7.3-SNAPSHOT-complete.jar \
18
+ -o <output_dir_full_path> \
19
+ -listener \
20
+ -visitor \
21
+ -package MYGrammar \
22
+ -Dlanguage=Ruby \
23
+ MYGrammarLexer.g4 MYGrammarParser.g4
24
+
25
+ ```
5
26
  ## Installation
6
27
 
7
28
  Add this line to your application's Gemfile:
@@ -25,25 +46,22 @@ Or clone the repository and build and install it yourself as:
25
46
  ## Usage
26
47
 
27
48
  ```ruby
28
- require 'modl/parser/MODLParserListener'
29
- require 'modl/parser/MODLParserVisitor'
30
- require 'modl/parser/MODLLexer'
31
- require 'modl/parser/MODLParser'
32
- require 'modl/parser/Parser'
33
- require 'modl/parser/class_processor'
34
- require 'json'
35
-
36
- module Modl::Parser
37
- class Interpreter
38
- def self.interpret(str)
39
- parsed = Modl::Parser::Parser.parse str
40
- interpreted = parsed.extract_json
41
- ClassProcessor.instance.process(parsed.global, interpreted)
42
- return interpreted if interpreted.is_a? String
43
- JSON.generate interpreted
44
- end
45
- end
46
- end
49
+ require './MYGrammarParserListener'
50
+ require './MYGrammarParserBaseListener'
51
+ require './MYGrammarParserVisitor'
52
+ require './MYGrammarLexer'
53
+ require './MYGrammarParser'
54
+
55
+ str = 'a=b'
56
+ lexer = MYGrammar::MYGrammarLexer.new(Antlr4::Runtime::CharStreams.from_string(str, 'String'))
57
+ lexer.remove_error_listeners
58
+
59
+ tokens = Antlr4::Runtime::CommonTokenStream.new(lexer)
60
+
61
+ parser = MYGrammar::MYGrammarParser.new(tokens)
62
+
63
+ parsed = MYGrammar::MYGrammarParserBaseListener.new
64
+ parser.my_grammar_entry_rule.enter_rule(parsed)
47
65
  ```
48
66
 
49
67
  ## Development
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.description = %q{This gem implements a runtime for ANTLR4 in Ruby for lexers and parsers generated using the Ruby language target.}
14
14
  spec.homepage = "https://github.com/MODLanguage/antlr4-ruby-runtime"
15
15
  spec.license = "MIT"
16
-
16
+
17
17
  # Specify which files should be added to the gem when it is released.
18
18
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
19
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib", "ext"]
25
25
 
26
- spec.add_development_dependency "bundler", "~> 2.0"
27
26
  spec.add_development_dependency "rake", "~> 10.0"
28
27
  spec.add_development_dependency "rspec", "~> 3.0"
29
28
  spec.extensions = %w[ext/rumourhash/extconf.rb]
@@ -3,10 +3,148 @@ require 'singleton'
3
3
  require 'ostruct'
4
4
  require 'weakref'
5
5
 
6
- require "rumourhash/rumourhash"
6
+ require 'rumourhash/rumourhash'
7
7
 
8
8
  module Antlr4
9
9
  module Runtime
10
+ autoload :AbstractParseTreeVisitor, 'antlr4/runtime/abstract_parse_tree_visitor'
11
+ autoload :AbstractPredicateTransition, 'antlr4/runtime/abstract_predicate_transition'
12
+ autoload :ActionTransition, 'antlr4/runtime/action_transition'
13
+ autoload :AmbiguityInfo, 'antlr4/runtime/ambiguity_info'
14
+ autoload :ANTLRErrorListener, 'antlr4/runtime/antlr_error_listener'
15
+ autoload :ANTLRErrorStrategy, 'antlr4/runtime/antlr_error_strategy'
16
+ autoload :ANTLRFileStream, 'antlr4/runtime/antlr_file_stream'
17
+ autoload :ANTLRInputStream, 'antlr4/runtime/antlr_input_stream'
18
+ autoload :Array2DHashSet, 'antlr4/runtime/array_2d_hash_set'
19
+ autoload :ArrayPredictionContext, 'antlr4/runtime/array_prediction_context'
20
+ autoload :ATN, 'antlr4/runtime/atn'
21
+ autoload :ATNConfig, 'antlr4/runtime/atn_config'
22
+ autoload :ATNConfigSet, 'antlr4/runtime/atn_config_set'
23
+ autoload :ATNDeserializationOptions, 'antlr4/runtime/atn_deserialization_options'
24
+ autoload :ATNDeserializer, 'antlr4/runtime/atn_deserializer'
25
+ autoload :ATNSimulator, 'antlr4/runtime/atn_simulator'
26
+ autoload :ATNState, 'antlr4/runtime/atn_state'
27
+ autoload :ATNType, 'antlr4/runtime/atn_type'
28
+ autoload :AtomTransition, 'antlr4/runtime/atom_transition'
29
+ autoload :BailErrorStrategy, 'antlr4/runtime/bail_error_strategy'
30
+ autoload :BaseErrorListener, 'antlr4/runtime/base_error_listener'
31
+ autoload :BasicBlockStartState, 'antlr4/runtime/basic_block_start_state'
32
+ autoload :BasicState, 'antlr4/runtime/basic_state'
33
+ autoload :BitSet, 'antlr4/runtime/bit_set'
34
+ autoload :BlockEndState, 'antlr4/runtime/block_end_state'
35
+ autoload :BlockStartState, 'antlr4/runtime/block_start_state'
36
+ autoload :BufferedTokenStream, 'antlr4/runtime/buffered_token_stream'
37
+ autoload :CharStream, 'antlr4/runtime/char_stream'
38
+ autoload :CharStreams, 'antlr4/runtime/char_streams'
39
+ autoload :Chunk, 'antlr4/runtime/chunk'
40
+ autoload :CodePointCharStream, 'antlr4/runtime/code_point_char_stream'
41
+ autoload :CommonToken, 'antlr4/runtime/common_token'
42
+ autoload :CommonTokenFactory, 'antlr4/runtime/common_token_factory'
43
+ autoload :CommonTokenStream, 'antlr4/runtime/common_token_stream'
44
+ autoload :ConsoleErrorListener, 'antlr4/runtime/console_error_listener'
45
+ autoload :ContextSensitivityInfo, 'antlr4/runtime/context_sensitivity_info'
46
+ autoload :DecisionEventInfo, 'antlr4/runtime/decision_event_info'
47
+ autoload :DecisionInfo, 'antlr4/runtime/decision_info'
48
+ autoload :DecisionState, 'antlr4/runtime/decision_state'
49
+ autoload :DefaultErrorStrategy, 'antlr4/runtime/default_error_strategy'
50
+ autoload :DFA, 'antlr4/runtime/dfa'
51
+ autoload :DFASerializer, 'antlr4/runtime/dfa_serializer'
52
+ autoload :DFAState, 'antlr4/runtime/dfa_state'
53
+ autoload :DiagnosticErrorListener, 'antlr4/runtime/diagnostic_error_listener'
54
+ autoload :DoubleKeyMap, 'antlr4/runtime/double_key_map'
55
+ autoload :EmptyPredictionContext, 'antlr4/runtime/empty_prediction_context'
56
+ autoload :EpsilonTransition, 'antlr4/runtime/epsilon_transition'
57
+ autoload :EqualityComparator, 'antlr4/runtime/equality_comparator'
58
+ autoload :ErrorInfo, 'antlr4/runtime/error_info'
59
+ autoload :ErrorNode, 'antlr4/runtime/error_node'
60
+ autoload :ErrorNodeImpl, 'antlr4/runtime/error_node_impl'
61
+ autoload :FailedPredicateException, 'antlr4/runtime/failed_predicate_exception'
62
+ autoload :FlexibleHashMap, 'antlr4/runtime/flexible_hash_map'
63
+ autoload :InputMismatchException, 'antlr4/runtime/input_mismatch_exception'
64
+ autoload :IntStream, 'antlr4/runtime/int_stream'
65
+ autoload :Integer, 'antlr4/runtime/integer'
66
+ autoload :Interval, 'antlr4/runtime/interval'
67
+ autoload :IntervalSet, 'antlr4/runtime/interval_set'
68
+ autoload :Lexer, 'antlr4/runtime/lexer'
69
+ autoload :LexerAction, 'antlr4/runtime/lexer_action'
70
+ autoload :LexerActionExecutor, 'antlr4/runtime/lexer_action_executor'
71
+ autoload :LexerActionType, 'antlr4/runtime/lexer_action_type'
72
+ autoload :LexerATNConfig, 'antlr4/runtime/lexer_atn_config'
73
+ autoload :LexerATNSimulator, 'antlr4/runtime/lexer_atn_simulator'
74
+ autoload :LexerChannelAction, 'antlr4/runtime/lexer_channel_action'
75
+ autoload :LexerCustomAction, 'antlr4/runtime/lexer_custom_action'
76
+ autoload :LexerDfaSerializer, 'antlr4/runtime/lexer_dfa_serializer'
77
+ autoload :LexerIndexedCustomAction, 'antlr4/runtime/lexer_indexed_custom_action'
78
+ autoload :LexerModeAction, 'antlr4/runtime/lexer_mode_action'
79
+ autoload :LexerMoreAction, 'antlr4/runtime/lexer_more_action'
80
+ autoload :LexerNoViableAltException, 'antlr4/runtime/lexer_no_viable_alt_exception'
81
+ autoload :LexerPopModeAction, 'antlr4/runtime/lexer_pop_mode_action'
82
+ autoload :LexerPushModeAction, 'antlr4/runtime/lexer_push_mode_action'
83
+ autoload :LexerSkipAction, 'antlr4/runtime/lexer_skip_action'
84
+ autoload :LexerTypeAction, 'antlr4/runtime/lexer_type_action'
85
+ autoload :LL1Analyzer, 'antlr4/runtime/ll1_analyzer'
86
+ autoload :LookaheadEventInfo, 'antlr4/runtime/lookahead_event_info'
87
+ autoload :LoopEndState, 'antlr4/runtime/loop_end_state'
88
+ autoload :MurmurHash, 'antlr4/runtime/murmur_hash'
89
+ autoload :NoViableAltException, 'antlr4/runtime/no_viable_alt_exception'
90
+ autoload :NotSetTransition, 'antlr4/runtime/not_set_transition'
91
+ autoload :ObjectEqualityComparator, 'antlr4/runtime/object_equality_comparator'
92
+ autoload :OrderedATNConfigSet, 'antlr4/runtime/ordered_atn_config_set'
93
+ autoload :ParseCancellationException, 'antlr4/runtime/parse_cancellation_exception'
94
+ autoload :ParseTree, 'antlr4/runtime/parse_tree'
95
+ autoload :ParseTreeListener, 'antlr4/runtime/parse_tree_listener'
96
+ autoload :ParseTreeVisitor, 'antlr4/runtime/parse_tree_visitor'
97
+ autoload :Parser, 'antlr4/runtime/parser'
98
+ autoload :ParserATNSimulator, 'antlr4/runtime/parser_atn_simulator'
99
+ autoload :ParserRuleContext, 'antlr4/runtime/parser_rule_context'
100
+ autoload :PlusBlockStartState, 'antlr4/runtime/plus_block_start_state'
101
+ autoload :PlusLoopbackState, 'antlr4/runtime/plus_loopback_state'
102
+ autoload :PrecedencePredicateTransition, 'antlr4/runtime/precedence_predicate_transition'
103
+ autoload :Predicate, 'antlr4/runtime/predicate'
104
+ autoload :PredicateEvalInfo, 'antlr4/runtime/predicate_eval_info'
105
+ autoload :PredicateTransition, 'antlr4/runtime/predicate_transition'
106
+ autoload :PredictionContext, 'antlr4/runtime/prediction_context'
107
+ autoload :PredictionContextCache, 'antlr4/runtime/prediction_context_cache'
108
+ autoload :PredictionContextUtils, 'antlr4/runtime/prediction_context_utils'
109
+ autoload :PredictionMode, 'antlr4/runtime/prediction_mode'
110
+ autoload :ProfilingATNSimulator, 'antlr4/runtime/profiling_atn_simulator'
111
+ autoload :ProxyErrorListener, 'antlr4/runtime/proxy_error_listener'
112
+ autoload :RangeTransition, 'antlr4/runtime/range_transition'
113
+ autoload :RecognitionException, 'antlr4/runtime/recognition_exception'
114
+ autoload :Recognizer, 'antlr4/runtime/recognizer'
115
+ autoload :RuleContext, 'antlr4/runtime/rule_context'
116
+ autoload :RuleContextWithAltNum, 'antlr4/runtime/rule_context_with_alt_num'
117
+ autoload :RuleNode, 'antlr4/runtime/rule_node'
118
+ autoload :RuleStartState, 'antlr4/runtime/rule_start_state'
119
+ autoload :RuleStopState, 'antlr4/runtime/rule_stop_state'
120
+ autoload :RuleTagToken, 'antlr4/runtime/rule_tag_token'
121
+ autoload :RuleTransition, 'antlr4/runtime/rule_transition'
122
+ autoload :SemanticContext, 'antlr4/runtime/semantic_context'
123
+ autoload :SetTransition, 'antlr4/runtime/set_transition'
124
+ autoload :SingletonPredictionContext, 'antlr4/runtime/singleton_prediction_context'
125
+ autoload :StarBlockStartState, 'antlr4/runtime/star_block_start_state'
126
+ autoload :StarLoopEntryState, 'antlr4/runtime/star_loop_entry_state'
127
+ autoload :StarLoopbackState, 'antlr4/runtime/star_loopback_state'
128
+ autoload :SyntaxTree, 'antlr4/runtime/syntax_tree'
129
+ autoload :TagChunk, 'antlr4/runtime/tag_chunk'
130
+ autoload :TerminalNode, 'antlr4/runtime/terminal_node'
131
+ autoload :TerminalNodeImpl, 'antlr4/runtime/terminal_node_impl'
132
+ autoload :TextChunk, 'antlr4/runtime/text_chunk'
133
+ autoload :Token, 'antlr4/runtime/token'
134
+ autoload :TokenStream, 'antlr4/runtime/token_stream'
135
+ autoload :TokenTagToken, 'antlr4/runtime/token_tag_token'
136
+ autoload :TokensStartState, 'antlr4/runtime/tokens_start_state'
137
+ autoload :Transition, 'antlr4/runtime/transition'
138
+ autoload :Tree, 'antlr4/runtime/tree'
139
+ autoload :Trees, 'antlr4/runtime/trees'
140
+ autoload :Triple, 'antlr4/runtime/triple'
141
+ autoload :Utils, 'antlr4/runtime/utils'
142
+ autoload :UUID, 'antlr4/runtime/uuid'
143
+ autoload :Version, 'antlr4/runtime/version'
144
+ autoload :Vocabulary, 'antlr4/runtime/vocabulary'
145
+ autoload :VocabularyImpl, 'antlr4/runtime/vocabulary_impl'
146
+ autoload :WildcardTransition, 'antlr4/runtime/wildcard_transition'
147
+ autoload :WritableToken, 'antlr4/runtime/writable_token'
10
148
  end
11
149
  end
12
150
 
@@ -17,21 +155,3 @@ end
17
155
  module BitCount
18
156
 
19
157
  end
20
-
21
- require 'antlr4/runtime/interval'
22
- require 'antlr4/runtime/char_streams'
23
- require 'antlr4/runtime/common_token_stream'
24
- require 'antlr4/runtime/prediction_context_cache'
25
- require 'antlr4/runtime/vocabulary_impl'
26
- require 'antlr4/runtime/dfa'
27
- require 'antlr4/runtime/atn_deserializer'
28
- require 'antlr4/runtime/lexer_atn_simulator'
29
- require 'antlr4/runtime/parser_atn_simulator'
30
- require 'antlr4/runtime/parser_rule_context'
31
- require 'antlr4/runtime/lexer'
32
- require 'antlr4/runtime/parser'
33
- require 'antlr4/runtime/parse_tree_listener'
34
- require 'antlr4/runtime/parse_tree_visitor'
35
- require 'antlr4/runtime/abstract_parse_tree_visitor'
36
- require 'antlr4/runtime/recognition_exception'
37
- require 'antlr4/runtime/utils'
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/transition'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class AbstractPredicateTransition < Transition
@@ -8,4 +6,4 @@ module Antlr4::Runtime
8
6
  end
9
7
  end
10
8
 
11
- end
9
+ end
@@ -1,6 +1,3 @@
1
- require 'antlr4/runtime/object_equality_comparator'
2
- require 'antlr4/runtime/murmur_hash'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class Array2DHashSet
@@ -468,4 +465,4 @@ module Antlr4::Runtime
468
465
  raise StandardError, '@nElements != oldSize' if @n_elements != old_size
469
466
  end
470
467
  end
471
- end
468
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/ll1_analyzer'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class IllegalArgumentException < RuntimeError
@@ -97,4 +95,4 @@ module Antlr4::Runtime
97
95
  expected
98
96
  end
99
97
  end
100
- end
98
+ end
@@ -137,4 +137,4 @@ module Antlr4::Runtime
137
137
  @_hash = hash_code
138
138
  end
139
139
  end
140
- end
140
+ end
@@ -1,6 +1,3 @@
1
- require 'antlr4/runtime/array_2d_hash_set'
2
- require 'antlr4/runtime/atn'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class ATNConfigSet
@@ -147,4 +144,4 @@ module Antlr4::Runtime
147
144
  @configs.length
148
145
  end
149
146
  end
150
- end
147
+ end
@@ -1,37 +1,3 @@
1
- require 'antlr4/runtime/uuid'
2
- require 'antlr4/runtime/atn_deserialization_options'
3
- require 'antlr4/runtime/atn_type'
4
- require 'antlr4/runtime/atn_state'
5
- require 'antlr4/runtime/interval_set'
6
- require 'antlr4/runtime/transition'
7
- require 'antlr4/runtime/epsilon_transition'
8
- require 'antlr4/runtime/set_transition'
9
- require 'antlr4/runtime/not_set_transition'
10
- require 'antlr4/runtime/action_transition'
11
- require 'antlr4/runtime/atom_transition'
12
- require 'antlr4/runtime/rule_transition'
13
- require 'antlr4/runtime/range_transition'
14
- require 'antlr4/runtime/lexer_action_type'
15
- require 'antlr4/runtime/lexer_skip_action'
16
- require 'antlr4/runtime/lexer_push_mode_action'
17
- require 'antlr4/runtime/lexer_pop_mode_action'
18
- require 'antlr4/runtime/lexer_type_action'
19
- require 'antlr4/runtime/lexer_channel_action'
20
-
21
- require 'antlr4/runtime/tokens_start_state'
22
- require 'antlr4/runtime/block_start_state'
23
- require 'antlr4/runtime/basic_block_start_state'
24
- require 'antlr4/runtime/star_block_start_state'
25
- require 'antlr4/runtime/star_loop_entry_state'
26
- require 'antlr4/runtime/block_end_state'
27
- require 'antlr4/runtime/loop_end_state'
28
- require 'antlr4/runtime/rule_start_state'
29
- require 'antlr4/runtime/rule_stop_state'
30
- require 'antlr4/runtime/basic_state'
31
- require 'antlr4/runtime/plus_block_start_state'
32
- require 'antlr4/runtime/plus_loopback_state'
33
- require 'antlr4/runtime/star_loopback_state'
34
-
35
1
  module Antlr4::Runtime
36
2
 
37
3
  class UnsupportedOperationException < StandardError
@@ -734,4 +700,4 @@ module Antlr4::Runtime
734
700
  end
735
701
  end
736
702
  end
737
- end
703
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/dfa_state'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class ATNSimulator
@@ -66,4 +64,4 @@ module Antlr4::Runtime
66
64
  ATNDeserializer.new.state_factory(type, rule_index)
67
65
  end
68
66
  end
69
- end
67
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/antlr_error_listener'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class BaseErrorListener < ANTLRErrorListener
@@ -15,4 +13,4 @@ module Antlr4::Runtime
15
13
  def report_context_sensitivity(_recognizer, _dfa, _start_index, _stop_index, _prediction, _configs)
16
14
  end
17
15
  end
18
- end
16
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/decision_state'
2
-
3
1
  module Antlr4::Runtime
4
2
  class BlockStartState < DecisionState
5
3
  attr_accessor :end_state
@@ -9,4 +7,4 @@ module Antlr4::Runtime
9
7
  @end_state = nil
10
8
  end
11
9
  end
12
- end
10
+ end
@@ -1,6 +1,3 @@
1
- require 'antlr4/runtime/writable_token'
2
- require 'antlr4/runtime/token_stream'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class BufferedTokenStream < TokenStream
@@ -332,4 +329,4 @@ module Antlr4::Runtime
332
329
  end
333
330
  end
334
331
  end
335
- end
332
+ end
@@ -1,6 +1,4 @@
1
- require 'antlr4/runtime/int_stream'
2
-
3
1
  module Antlr4::Runtime
4
2
  class CharStream < IntStream
5
3
  end
6
- end
4
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/code_point_char_stream'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class CharStreams
@@ -9,4 +7,4 @@ module Antlr4::Runtime
9
7
  CodePointCharStream.new(0, s.length, source_name, s.bytes)
10
8
  end
11
9
  end
12
- end
10
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/common_token'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class CommonTokenFactory
@@ -27,4 +25,4 @@ module Antlr4::Runtime
27
25
  CommonToken.create2(type, text)
28
26
  end
29
27
  end
30
- end
28
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/buffered_token_stream'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class CommonTokenStream < BufferedTokenStream
@@ -60,4 +58,4 @@ module Antlr4::Runtime
60
58
  n
61
59
  end
62
60
  end
63
- end
61
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/base_error_listener'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class ConsoleErrorListener < BaseErrorListener
@@ -9,4 +7,4 @@ module Antlr4::Runtime
9
7
  STDERR.puts 'line ' << line.to_s << ':' << char_position_in_line.to_s << ' ' << msg.to_s << ''
10
8
  end
11
9
  end
12
- end
10
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/atn_state'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class DecisionState < ATNState
@@ -12,4 +10,4 @@ module Antlr4::Runtime
12
10
  @non_greedy = false
13
11
  end
14
12
  end
15
- end
13
+ end
@@ -1,7 +1,3 @@
1
- require 'antlr4/runtime/antlr_error_strategy'
2
- require 'antlr4/runtime/input_mismatch_exception'
3
- require 'antlr4/runtime/no_viable_alt_exception'
4
-
5
1
  module Antlr4::Runtime
6
2
 
7
3
  class DefaultErrorStrategy < ANTLRErrorStrategy
@@ -115,7 +111,7 @@ module Antlr4::Runtime
115
111
  # System.err.println("at loop back: "+s.getClass().getSimpleName())
116
112
  report_unwanted_token(recognizer)
117
113
  expecting = recognizer.expected_tokens
118
- what_follows_loop_iteration_or_rule = expecting.or(error_recovery_set(recognizer))
114
+ what_follows_loop_iteration_or_rule = expecting || error_recovery_set(recognizer)
119
115
  consume_until(recognizer, what_follows_loop_iteration_or_rule)
120
116
 
121
117
  else # do nothing if we can't identify the exact kind of ATN state end
@@ -311,4 +307,4 @@ module Antlr4::Runtime
311
307
  end
312
308
  end
313
309
  end
314
- end
310
+ end
@@ -1,6 +1,3 @@
1
- require 'antlr4/runtime/dfa_serializer'
2
- require 'antlr4/runtime/lexer_dfa_serializer'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class DFA
@@ -94,4 +91,4 @@ module Antlr4::Runtime
94
91
  serializer.to_s
95
92
  end
96
93
  end
97
- end
94
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/atn_config_set'
2
-
3
1
  module Antlr4::Runtime
4
2
  class DFAState
5
3
  attr_accessor :state_number
@@ -106,4 +104,4 @@ module Antlr4::Runtime
106
104
  buf.to_s
107
105
  end
108
106
  end
109
- end
107
+ end
@@ -1,4 +1,3 @@
1
- require 'antlr4/runtime/singleton_prediction_context'
2
1
  module Antlr4::Runtime
3
2
 
4
3
  class EmptyPredictionContext < SingletonPredictionContext
@@ -32,4 +31,4 @@ module Antlr4::Runtime
32
31
  '$'
33
32
  end
34
33
  end
35
- end
34
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/recognition_exception'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class InputMismatchException < RecognitionException
@@ -17,4 +15,4 @@ module Antlr4::Runtime
17
15
  result
18
16
  end
19
17
  end
20
- end
18
+ end
@@ -1,8 +1,3 @@
1
- require 'antlr4/runtime/recognizer'
2
- require 'antlr4/runtime/token'
3
- require 'antlr4/runtime/common_token_factory'
4
- require 'antlr4/runtime/lexer_no_viable_alt_exception'
5
-
6
1
  module Antlr4::Runtime
7
2
 
8
3
  class Lexer < Recognizer
@@ -254,4 +249,4 @@ module Antlr4::Runtime
254
249
  @_input.consume
255
250
  end
256
251
  end
257
- end
252
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/lexer_indexed_custom_action'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class LexerActionExecutor
@@ -72,4 +70,4 @@ module Antlr4::Runtime
72
70
  @hash_code == obj.hash_code && (@lexer_actions == obj._a)
73
71
  end
74
72
  end
75
- end
73
+ end
@@ -1,9 +1,16 @@
1
- require 'antlr4/runtime/atn_config'
2
- require 'antlr4/runtime/semantic_context'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class LexerATNConfig < ATNConfig
4
+ class << self
5
+ def create_from_config(*args)
6
+ new.tap { |atn| atn.lexer_atn_config3(*args) }
7
+ end
8
+
9
+ def create_from_config2(*args)
10
+ new.tap { |atn| atn.lexer_atn_config5(*args) }
11
+ end
12
+ end
13
+
7
14
  attr_accessor :passed_through_non_greedy_decision
8
15
  attr_accessor :lexer_action_executor
9
16
 
@@ -47,4 +54,4 @@ module Antlr4::Runtime
47
54
  source.passed_through_non_greedy_decision || target.is_a?(DecisionState) && target.non_greedy
48
55
  end
49
56
  end
50
- end
57
+ end
@@ -1,8 +1,3 @@
1
- require 'antlr4/runtime/atn_simulator'
2
- require 'antlr4/runtime/lexer_atn_config'
3
- require 'antlr4/runtime/ordered_atn_config_set'
4
- require 'antlr4/runtime/lexer_action_executor'
5
-
6
1
  module Antlr4::Runtime
7
2
 
8
3
  class LexerATNSimulator < ATNSimulator
@@ -498,7 +493,7 @@ module Antlr4::Runtime
498
493
  end
499
494
 
500
495
  def text(input) # index is first lookahead char, don' t include.
501
- input.text(Interval.of(start_index, input.index - 1))
496
+ input.text(Interval.of(@start_index, input.index - 1))
502
497
  end
503
498
 
504
499
  def consume(input)
@@ -519,4 +514,4 @@ module Antlr4::Runtime
519
514
  "'" + t.to_s + "'"
520
515
  end
521
516
  end
522
- end
517
+ end
@@ -1,7 +1,7 @@
1
1
  module Antlr4::Runtime
2
2
 
3
3
  class LexerCustomAction < LexerAction
4
- attr_reader :ruleIndex
4
+ attr_reader :rule_index
5
5
  attr_reader :action_index
6
6
 
7
7
  def initialize(rule_index, action_index)
@@ -46,4 +46,4 @@ module Antlr4::Runtime
46
46
  @rule_index == other.rule_index && @action_index == other.action_index
47
47
  end
48
48
  end
49
- end
49
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/lexer_action'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class LexerSkipAction < LexerAction
@@ -40,4 +38,4 @@ module Antlr4::Runtime
40
38
  'skip'
41
39
  end
42
40
  end
43
- end
41
+ end
@@ -1,9 +1,3 @@
1
- require 'antlr4/runtime/abstract_predicate_transition'
2
- require 'antlr4/runtime/wildcard_transition'
3
- require 'antlr4/runtime/not_set_transition'
4
- require 'antlr4/runtime/rule_transition'
5
- require 'antlr4/runtime/rule_stop_state'
6
-
7
1
  module Antlr4::Runtime
8
2
 
9
3
  class LL1Analyzer
@@ -130,4 +124,4 @@ module Antlr4::Runtime
130
124
  end
131
125
  end
132
126
  end
133
- end
127
+ end
@@ -1,7 +1,5 @@
1
- require 'antlr4/runtime/syntax_tree'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class ParseTree < SyntaxTree
6
4
  end
7
- end
5
+ end
@@ -1,8 +1,3 @@
1
- require 'antlr4/runtime/parse_tree_listener'
2
- require 'antlr4/runtime/default_error_strategy'
3
- require 'antlr4/runtime/terminal_node_impl'
4
- require 'antlr4/runtime/error_node_impl'
5
-
6
1
  module Antlr4::Runtime
7
2
 
8
3
  class Parser < Recognizer
@@ -519,4 +514,4 @@ module Antlr4::Runtime
519
514
  !@_tracer.nil?
520
515
  end
521
516
  end
522
- end
517
+ end
@@ -1,7 +1,3 @@
1
- require 'antlr4/runtime/atn_simulator'
2
- require 'antlr4/runtime/prediction_mode'
3
- require 'antlr4/runtime/double_key_map'
4
-
5
1
  module Antlr4::Runtime
6
2
 
7
3
  class ParserATNSimulator < ATNSimulator
@@ -1168,4 +1164,4 @@ module Antlr4::Runtime
1168
1164
  end
1169
1165
 
1170
1166
  end
1171
- end
1167
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/rule_context'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class ParserRuleContext < RuleContext
@@ -183,4 +181,4 @@ module Antlr4::Runtime
183
181
  'ParserRuleContext' + rules + '' + 'start=' + @start + ', stop=' + @stop + 'end'
184
182
  end
185
183
  end
186
- end
184
+ end
@@ -32,4 +32,4 @@ module Antlr4::Runtime
32
32
  'pred_' + @rule_index + ':' + @pred_index
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/integer'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class PredictionContext
@@ -100,4 +98,4 @@ module Antlr4::Runtime
100
98
  false
101
99
  end
102
100
  end
103
- end
101
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/empty_prediction_context'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class PredictionContextCache
@@ -25,4 +23,4 @@ module Antlr4::Runtime
25
23
  @cache.size
26
24
  end
27
25
  end
28
- end
26
+ end
@@ -1,6 +1,3 @@
1
- require 'antlr4/runtime/murmur_hash'
2
- require 'antlr4/runtime/array_prediction_context'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class PredictionContextUtils
@@ -404,4 +401,4 @@ module Antlr4::Runtime
404
401
  MurmurHash.hash_ints_objs(return_states, parents)
405
402
  end
406
403
  end
407
- end
404
+ end
@@ -1,6 +1,3 @@
1
- require 'antlr4/runtime/flexible_hash_map'
2
- require 'antlr4/runtime/bit_set'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class PredictionMode
@@ -210,4 +207,4 @@ module Antlr4::Runtime
210
207
  viable_alts.next_set_bit(0)
211
208
  end
212
209
  end
213
- end
210
+ end
@@ -1,6 +1,3 @@
1
- require 'antlr4/runtime/console_error_listener'
2
- require 'antlr4/runtime/proxy_error_listener'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class Recognizer
@@ -133,4 +130,4 @@ module Antlr4::Runtime
133
130
  def action(_localctx, _rule_index, _action_index)
134
131
  end
135
132
  end
136
- end
133
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/rule_node'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class RuleContext < RuleNode
@@ -128,4 +126,4 @@ module Antlr4::Runtime
128
126
  buf
129
127
  end
130
128
  end
131
- end
129
+ end
@@ -1,8 +1,6 @@
1
- require 'antlr4/runtime/parse_tree'
2
-
3
1
  module Antlr4::Runtime
4
2
  class RuleNode < ParseTree
5
3
  def rule_context
6
4
  end
7
5
  end
8
- end
6
+ end
@@ -1,6 +1,3 @@
1
- require 'antlr4/runtime/prediction_context'
2
- require 'antlr4/runtime/prediction_context_utils'
3
-
4
1
  module Antlr4::Runtime
5
2
 
6
3
  class SingletonPredictionContext < PredictionContext
@@ -53,4 +50,4 @@ module Antlr4::Runtime
53
50
  @return_state.to_s + ' ' + up
54
51
  end
55
52
  end
56
- end
53
+ end
@@ -1,6 +1,4 @@
1
- require 'antlr4/runtime/tree'
2
-
3
1
  module Antlr4::Runtime
4
2
  class SyntaxTree < Tree
5
3
  end
6
- end
4
+ end
@@ -1,4 +1,3 @@
1
- require 'antlr4/runtime/int_stream'
2
1
  module Antlr4::Runtime
3
2
 
4
3
  class Token
@@ -10,4 +9,4 @@ module Antlr4::Runtime
10
9
  HIDDEN_CHANNEL = 1
11
10
  MIN_USER_CHANNEL_VALUE = 2
12
11
  end
13
- end
12
+ end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/decision_state'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class TokensStartState < DecisionState
@@ -11,4 +9,4 @@ module Antlr4::Runtime
11
9
  TOKEN_START
12
10
  end
13
11
  end
14
- end
12
+ end
@@ -1,5 +1,5 @@
1
1
  module Antlr4
2
2
  module Runtime
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,5 +1,3 @@
1
- require 'antlr4/runtime/vocabulary'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class VocabularyImpl < Vocabulary
@@ -79,4 +77,4 @@ module Antlr4::Runtime
79
77
  Integer.to_s(token_type)
80
78
  end
81
79
  end
82
- end
80
+ end
@@ -1,7 +1,5 @@
1
- require 'antlr4/runtime/token'
2
-
3
1
  module Antlr4::Runtime
4
2
 
5
3
  class WritableToken < Token
6
4
  end
7
- end
5
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: antlr4-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Walmsley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +52,6 @@ files:
66
52
  - ".travis.yml"
67
53
  - CODE_OF_CONDUCT.md
68
54
  - Gemfile
69
- - Gemfile.lock
70
55
  - LICENSE.txt
71
56
  - README.md
72
57
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,35 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- antlr4-runtime (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.3)
10
- rake (10.5.0)
11
- rspec (3.8.0)
12
- rspec-core (~> 3.8.0)
13
- rspec-expectations (~> 3.8.0)
14
- rspec-mocks (~> 3.8.0)
15
- rspec-core (3.8.0)
16
- rspec-support (~> 3.8.0)
17
- rspec-expectations (3.8.3)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.8.0)
20
- rspec-mocks (3.8.0)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.8.0)
23
- rspec-support (3.8.0)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- antlr4-runtime!
30
- bundler (~> 2.0)
31
- rake (~> 10.0)
32
- rspec (~> 3.0)
33
-
34
- BUNDLED WITH
35
- 2.0.1