expressir 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +30 -17
  3. data/.gitignore +1 -0
  4. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +30 -5
  5. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +8 -0
  6. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +31 -15
  7. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +1 -1
  8. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +1 -5
  9. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +1 -5
  10. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +1 -6
  11. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +9 -6
  12. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +26 -12
  13. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +10 -3
  14. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +1 -1
  15. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +1 -1
  16. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +7 -1
  17. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +2 -2
  18. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +23 -10
  19. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +2 -2
  20. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +2 -2
  21. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +4 -4
  22. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +1 -1
  23. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +3 -3
  24. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +1 -1
  25. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +4 -4
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +8 -2
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +1 -1
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +39 -7
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +1 -1
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +5 -5
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +9 -2
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +11 -19
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +2 -3
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +4 -1
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +2 -2
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +7 -1
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +0 -2
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +8 -2
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +0 -2
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +7 -1
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +1 -1
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +1 -1
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +9 -2
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +8 -10
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +7 -1
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +9 -2
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +6 -2
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +14 -2
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +2 -2
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -1
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +1 -1
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +9 -9
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +7 -1
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -1
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +2 -2
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +1 -1
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +11 -1
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +40 -18
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +1 -1
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +29 -5
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +1 -1
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +1 -1
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +1 -1
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +1 -1
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +1 -1
  66. data/ext/express-parser/express_parser.cpp +20 -164
  67. data/ext/express-parser/extconf.rb +3 -4
  68. data/lib/expressir/express/parser.rb +17 -14
  69. data/lib/expressir/express/visitor.rb +3 -1
  70. data/lib/expressir/version.rb +1 -1
  71. metadata +2 -2
@@ -18,20 +18,33 @@ namespace antlr4 {
18
18
  /// of speed.
19
19
  class ANTLR4CPP_PUBLIC Lexer : public Recognizer, public TokenSource {
20
20
  public:
21
- static const size_t DEFAULT_MODE = 0;
22
- static const size_t MORE = static_cast<size_t>(-2);
23
- static const size_t SKIP = static_cast<size_t>(-3);
24
-
25
- static const size_t DEFAULT_TOKEN_CHANNEL = Token::DEFAULT_CHANNEL;
26
- static const size_t HIDDEN = Token::HIDDEN_CHANNEL;
27
- static const size_t MIN_CHAR_VALUE = 0;
28
- static const size_t MAX_CHAR_VALUE = 0x10FFFF;
21
+ #if __cplusplus >= 201703L
22
+ static constexpr size_t DEFAULT_MODE = 0;
23
+ static constexpr size_t MORE = std::numeric_limits<size_t>::max() - 1;
24
+ static constexpr size_t SKIP = std::numeric_limits<size_t>::max() - 2;
25
+
26
+ static constexpr size_t DEFAULT_TOKEN_CHANNEL = Token::DEFAULT_CHANNEL;
27
+ static constexpr size_t HIDDEN = Token::HIDDEN_CHANNEL;
28
+ static constexpr size_t MIN_CHAR_VALUE = 0;
29
+ static constexpr size_t MAX_CHAR_VALUE = 0x10FFFF;
30
+ #else
31
+ enum : size_t {
32
+ DEFAULT_MODE = 0,
33
+ MORE = static_cast<size_t>(-2), // std::numeric_limits<size_t>::max() - 1; doesn't work in VS 2013
34
+ SKIP = static_cast<size_t>(-3), // std::numeric_limits<size_t>::max() - 2; doesn't work in VS 2013
35
+
36
+ DEFAULT_TOKEN_CHANNEL = Token::DEFAULT_CHANNEL,
37
+ HIDDEN = Token::HIDDEN_CHANNEL,
38
+ MIN_CHAR_VALUE = 0,
39
+ MAX_CHAR_VALUE = 0x10FFFF,
40
+ };
41
+ #endif
29
42
 
30
43
  CharStream *_input; // Pure reference, usually from statically allocated instance.
31
44
 
32
45
  protected:
33
46
  /// How to create token objects.
34
- Ref<TokenFactory<CommonToken>> _factory;
47
+ TokenFactory<CommonToken> *_factory;
35
48
 
36
49
  public:
37
50
  /// The goal of all lexer rules/methods is to create a token object.
@@ -100,7 +113,7 @@ namespace antlr4 {
100
113
  this->_factory = factory;
101
114
  }
102
115
 
103
- virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
116
+ virtual TokenFactory<CommonToken>* getTokenFactory() override;
104
117
 
105
118
  /// Set the char stream and reset the lexer
106
119
  virtual void setInputStream(IntStream *input) override;
@@ -82,11 +82,11 @@ std::string ListTokenSource::getSourceName() {
82
82
  return "List";
83
83
  }
84
84
 
85
- Ref<TokenFactory<CommonToken>> ListTokenSource::getTokenFactory() {
85
+ TokenFactory<CommonToken>* ListTokenSource::getTokenFactory() {
86
86
  return _factory;
87
87
  }
88
88
 
89
89
  void ListTokenSource::InitializeInstanceFields() {
90
90
  i = 0;
91
- _factory = CommonTokenFactory::DEFAULT;
91
+ _factory = CommonTokenFactory::DEFAULT.get();
92
92
  }
@@ -40,7 +40,7 @@ namespace antlr4 {
40
40
  private:
41
41
  /// This is the backing field for <seealso cref="#getTokenFactory"/> and
42
42
  /// <seealso cref="setTokenFactory"/>.
43
- Ref<TokenFactory<CommonToken>> _factory = CommonTokenFactory::DEFAULT;
43
+ TokenFactory<CommonToken> *_factory = CommonTokenFactory::DEFAULT.get();
44
44
 
45
45
  public:
46
46
  /// Constructs a new <seealso cref="ListTokenSource"/> instance from the specified
@@ -79,7 +79,7 @@ namespace antlr4 {
79
79
  this->_factory = factory;
80
80
  }
81
81
 
82
- virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
82
+ virtual TokenFactory<CommonToken>* getTokenFactory() override;
83
83
 
84
84
  private:
85
85
  void InitializeInstanceFields();
@@ -190,7 +190,7 @@ void Parser::removeParseListeners() {
190
190
  }
191
191
 
192
192
  void Parser::triggerEnterRuleEvent() {
193
- for (auto listener : _parseListeners) {
193
+ for (auto *listener : _parseListeners) {
194
194
  listener->enterEveryRule(_ctx);
195
195
  _ctx->enterRule(listener);
196
196
  }
@@ -208,7 +208,7 @@ size_t Parser::getNumberOfSyntaxErrors() {
208
208
  return _syntaxErrors;
209
209
  }
210
210
 
211
- Ref<TokenFactory<CommonToken>> Parser::getTokenFactory() {
211
+ TokenFactory<CommonToken>* Parser::getTokenFactory() {
212
212
  return _input->getTokenSource()->getTokenFactory();
213
213
  }
214
214
 
@@ -307,14 +307,14 @@ Token* Parser::consume() {
307
307
  tree::ErrorNode *node = createErrorNode(o);
308
308
  _ctx->addChild(node);
309
309
  if (_parseListeners.size() > 0) {
310
- for (auto listener : _parseListeners) {
310
+ for (auto *listener : _parseListeners) {
311
311
  listener->visitErrorNode(node);
312
312
  }
313
313
  }
314
314
  } else {
315
315
  tree::TerminalNode *node = _ctx->addChild(createTerminalNode(o));
316
316
  if (_parseListeners.size() > 0) {
317
- for (auto listener : _parseListeners) {
317
+ for (auto *listener : _parseListeners) {
318
318
  listener->visitTerminal(node);
319
319
  }
320
320
  }
@@ -193,7 +193,7 @@ namespace antlr4 {
193
193
  /// <seealso cref= #notifyErrorListeners </seealso>
194
194
  virtual size_t getNumberOfSyntaxErrors();
195
195
 
196
- virtual Ref<TokenFactory<CommonToken>> getTokenFactory() override;
196
+ virtual TokenFactory<CommonToken>* getTokenFactory() override;
197
197
 
198
198
  /// <summary>
199
199
  /// Tell our token source and error strategy about a new way to create tokens. </summary>
@@ -38,8 +38,8 @@ void ParserRuleContext::copyFrom(ParserRuleContext *ctx) {
38
38
 
39
39
  // copy any error nodes to alt label node
40
40
  if (!ctx->children.empty()) {
41
- for (auto child : ctx->children) {
42
- auto errorNode = dynamic_cast<ErrorNode *>(child);
41
+ for (auto *child : ctx->children) {
42
+ auto *errorNode = dynamic_cast<ErrorNode *>(child);
43
43
  if (errorNode != nullptr) {
44
44
  errorNode->setParent(this);
45
45
  children.push_back(errorNode);
@@ -82,7 +82,7 @@ tree::TerminalNode* ParserRuleContext::getToken(size_t ttype, size_t i) {
82
82
  }
83
83
 
84
84
  size_t j = 0; // what token with ttype have we found?
85
- for (auto o : children) {
85
+ for (auto *o : children) {
86
86
  if (is<tree::TerminalNode *>(o)) {
87
87
  tree::TerminalNode *tnode = dynamic_cast<tree::TerminalNode *>(o);
88
88
  Token *symbol = tnode->getSymbol();
@@ -114,7 +114,7 @@ namespace antlr4 {
114
114
  template<typename T>
115
115
  std::vector<T *> getRuleContexts() {
116
116
  std::vector<T *> contexts;
117
- for (auto child : children) {
117
+ for (auto *child : children) {
118
118
  if (antlrcpp::is<T *>(child)) {
119
119
  contexts.push_back(dynamic_cast<T *>(child));
120
120
  }
@@ -26,28 +26,28 @@ void ProxyErrorListener::removeErrorListeners() {
26
26
  void ProxyErrorListener::syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line,
27
27
  size_t charPositionInLine, const std::string &msg, std::exception_ptr e) {
28
28
 
29
- for (auto listener : _delegates) {
29
+ for (auto *listener : _delegates) {
30
30
  listener->syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
31
31
  }
32
32
  }
33
33
 
34
34
  void ProxyErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
35
35
  bool exact, const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) {
36
- for (auto listener : _delegates) {
36
+ for (auto *listener : _delegates) {
37
37
  listener->reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
38
38
  }
39
39
  }
40
40
 
41
41
  void ProxyErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
42
42
  size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) {
43
- for (auto listener : _delegates) {
43
+ for (auto *listener : _delegates) {
44
44
  listener->reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs);
45
45
  }
46
46
  }
47
47
 
48
48
  void ProxyErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex,
49
49
  size_t prediction, atn::ATNConfigSet *configs) {
50
- for (auto listener : _delegates) {
50
+ for (auto *listener : _delegates) {
51
51
  listener->reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs);
52
52
  }
53
53
  }
@@ -11,7 +11,13 @@ namespace antlr4 {
11
11
 
12
12
  class ANTLR4CPP_PUBLIC Recognizer {
13
13
  public:
14
- static const size_t EOF = static_cast<size_t>(-1); // std::numeric_limits<size_t>::max(); doesn't work in VS 2013.
14
+ #if __cplusplus >= 201703L
15
+ static constexpr size_t EOF = std::numeric_limits<size_t>::max();
16
+ #else
17
+ enum : size_t {
18
+ EOF = static_cast<size_t>(-1), // std::numeric_limits<size_t>::max(); doesn't work in VS 2013.
19
+ };
20
+ #endif
15
21
 
16
22
  Recognizer();
17
23
  Recognizer(Recognizer const&) = delete;
@@ -138,7 +144,7 @@ namespace antlr4 {
138
144
 
139
145
  virtual void setInputStream(IntStream *input) = 0;
140
146
 
141
- virtual Ref<TokenFactory<CommonToken>> getTokenFactory() = 0;
147
+ virtual TokenFactory<CommonToken>* getTokenFactory() = 0;
142
148
 
143
149
  template<typename T1>
144
150
  void setTokenFactory(TokenFactory<T1> *input);
@@ -7,7 +7,7 @@
7
7
 
8
8
  using namespace antlr4;
9
9
 
10
- const std::string RuntimeMetaData::VERSION = "4.8";
10
+ const std::string RuntimeMetaData::VERSION = "4.9.2";
11
11
 
12
12
  std::string RuntimeMetaData::getRuntimeVersion() {
13
13
  return VERSION;
@@ -14,24 +14,50 @@ namespace antlr4 {
14
14
  /// we obtained this token.
15
15
  class ANTLR4CPP_PUBLIC Token {
16
16
  public:
17
- static const size_t INVALID_TYPE = 0;
17
+ #if __cplusplus >= 201703L
18
+ static constexpr size_t INVALID_TYPE = 0;
19
+ #else
20
+ enum : size_t {
21
+ INVALID_TYPE = 0,
22
+ };
23
+ #endif
18
24
 
19
25
  /// During lookahead operations, this "token" signifies we hit rule end ATN state
20
26
  /// and did not follow it despite needing to.
21
- static const size_t EPSILON = static_cast<size_t>(-2);
22
- static const size_t MIN_USER_TOKEN_TYPE = 1;
23
- static const size_t EOF = IntStream::EOF;
27
+ #if __cplusplus >= 201703L
28
+ static constexpr size_t EPSILON = std::numeric_limits<size_t>::max() - 1;
29
+ static constexpr size_t MIN_USER_TOKEN_TYPE = 1;
30
+ static constexpr size_t EOF = IntStream::EOF;
31
+ #else
32
+ enum : size_t {
33
+ EPSILON = static_cast<size_t>(-2), // std::numeric_limits<size_t>::max() - 1; doesn't work in VS 2013
34
+ MIN_USER_TOKEN_TYPE = 1,
35
+ EOF = IntStream::EOF,
36
+ };
37
+ #endif
24
38
 
25
39
  virtual ~Token();
26
40
 
27
41
  /// All tokens go to the parser (unless skip() is called in that rule)
28
42
  /// on a particular "channel". The parser tunes to a particular channel
29
43
  /// so that whitespace etc... can go to the parser on a "hidden" channel.
30
- static const size_t DEFAULT_CHANNEL = 0;
44
+ #if __cplusplus >= 201703L
45
+ static constexpr size_t DEFAULT_CHANNEL = 0;
46
+ #else
47
+ enum : size_t {
48
+ DEFAULT_CHANNEL = 0,
49
+ };
50
+ #endif
31
51
 
32
52
  /// Anything on different channel than DEFAULT_CHANNEL is not parsed
33
53
  /// by parser.
34
- static const size_t HIDDEN_CHANNEL = 1;
54
+ #if __cplusplus >= 201703L
55
+ static constexpr size_t HIDDEN_CHANNEL = 1;
56
+ #else
57
+ enum : size_t {
58
+ HIDDEN_CHANNEL = 1,
59
+ };
60
+ #endif
35
61
 
36
62
  /**
37
63
  * This is the minimum constant value which can be assigned to a
@@ -44,7 +70,13 @@ namespace antlr4 {
44
70
  *
45
71
  * @see Token#getChannel()
46
72
  */
47
- static const size_t MIN_USER_CHANNEL_VALUE = 2;
73
+ #if __cplusplus >= 201703L
74
+ static constexpr size_t MIN_USER_CHANNEL_VALUE = 2;
75
+ #else
76
+ enum : size_t {
77
+ MIN_USER_CHANNEL_VALUE = 2,
78
+ };
79
+ #endif
48
80
 
49
81
  /// Get the text of the token.
50
82
  virtual std::string getText() const = 0;
@@ -79,7 +79,7 @@ namespace antlr4 {
79
79
  /// creating <seealso cref="Token"/> objects from the input.
80
80
  /// </summary>
81
81
  /// <returns> The <seealso cref="TokenFactory"/> currently used by this token source. </returns>
82
- virtual Ref<TokenFactory<CommonToken>> getTokenFactory() = 0;
82
+ virtual TokenFactory<CommonToken>* getTokenFactory() = 0;
83
83
  };
84
84
 
85
85
  } // namespace antlr4
@@ -94,7 +94,7 @@ TokenStreamRewriter::TokenStreamRewriter(TokenStream *tokens_) : tokens(tokens_)
94
94
 
95
95
  TokenStreamRewriter::~TokenStreamRewriter() {
96
96
  for (auto program : _programs) {
97
- for (auto operation : program.second) {
97
+ for (auto *operation : program.second) {
98
98
  delete operation;
99
99
  }
100
100
  }
@@ -323,7 +323,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
323
323
 
324
324
  // Wipe prior inserts within range
325
325
  std::vector<InsertBeforeOp *> inserts = getKindOfOps<InsertBeforeOp>(rewrites, i);
326
- for (auto iop : inserts) {
326
+ for (auto *iop : inserts) {
327
327
  if (iop->index == rop->index) {
328
328
  // E.g., insert before 2, delete 2..2; update replace
329
329
  // text to include insert before, kill insert
@@ -339,7 +339,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
339
339
  }
340
340
  // Drop any prior replaces contained within
341
341
  std::vector<ReplaceOp*> prevReplaces = getKindOfOps<ReplaceOp>(rewrites, i);
342
- for (auto prevRop : prevReplaces) {
342
+ for (auto *prevRop : prevReplaces) {
343
343
  if (prevRop->index >= rop->index && prevRop->lastIndex <= rop->lastIndex) {
344
344
  // delete replace as it's a no-op.
345
345
  delete rewrites[prevRop->instructionIndex];
@@ -373,7 +373,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
373
373
  // combine current insert with prior if any at same index
374
374
 
375
375
  std::vector<InsertBeforeOp *> prevInserts = getKindOfOps<InsertBeforeOp>(rewrites, i);
376
- for (auto prevIop : prevInserts) {
376
+ for (auto *prevIop : prevInserts) {
377
377
  if (prevIop->index == iop->index) { // combine objects
378
378
  // convert to strings...we're in process of toString'ing
379
379
  // whole token buffer so no lazy eval issue with any templates
@@ -385,7 +385,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
385
385
  }
386
386
  // look for replaces where iop.index is in range; error
387
387
  std::vector<ReplaceOp*> prevReplaces = getKindOfOps<ReplaceOp>(rewrites, i);
388
- for (auto rop : prevReplaces) {
388
+ for (auto *rop : prevReplaces) {
389
389
  if (iop->index == rop->index) {
390
390
  rop->text = catOpText(&iop->text, &rop->text);
391
391
  delete rewrites[i];
@@ -86,8 +86,15 @@ namespace antlr4 {
86
86
  class ANTLR4CPP_PUBLIC TokenStreamRewriter {
87
87
  public:
88
88
  static const std::string DEFAULT_PROGRAM_NAME;
89
- static const size_t PROGRAM_INIT_SIZE = 100;
90
- static const size_t MIN_TOKEN_INDEX = 0;
89
+ #if __cplusplus >= 201703L
90
+ static constexpr size_t PROGRAM_INIT_SIZE = 100;
91
+ static constexpr size_t MIN_TOKEN_INDEX = 0;
92
+ #else
93
+ enum : size_t {
94
+ PROGRAM_INIT_SIZE = 100,
95
+ MIN_TOKEN_INDEX = 0,
96
+ };
97
+ #endif
91
98
 
92
99
  TokenStreamRewriter(TokenStream *tokens);
93
100
  virtual ~TokenStreamRewriter();
@@ -22,8 +22,7 @@ Vocabulary::Vocabulary(const std::vector<std::string> &literalNames,
22
22
  // See note here on -1 part: https://github.com/antlr/antlr4/pull/1146
23
23
  }
24
24
 
25
- Vocabulary::~Vocabulary() {
26
- }
25
+ Vocabulary::~Vocabulary() = default;
27
26
 
28
27
  Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames) {
29
28
  if (tokenNames.empty()) {
@@ -34,25 +33,18 @@ Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames
34
33
  std::vector<std::string> symbolicNames = tokenNames;
35
34
  std::locale locale;
36
35
  for (size_t i = 0; i < tokenNames.size(); i++) {
37
- std::string tokenName = tokenNames[i];
38
- if (tokenName == "") {
36
+ const std::string& tokenName = tokenNames[i];
37
+ if (tokenName.empty()) {
39
38
  continue;
39
+ } else if (tokenName.front() == '\'') {
40
+ symbolicNames[i].clear();
41
+ } else if (std::isupper(tokenName.front(), locale)) {
42
+ literalNames[i].clear();
43
+ } else {
44
+ // wasn't a literal or symbolic name
45
+ literalNames[i].clear();
46
+ symbolicNames[i].clear();
40
47
  }
41
-
42
- if (!tokenName.empty()) {
43
- char firstChar = tokenName[0];
44
- if (firstChar == '\'') {
45
- symbolicNames[i] = "";
46
- continue;
47
- } else if (std::isupper(firstChar, locale)) {
48
- literalNames[i] = "";
49
- continue;
50
- }
51
- }
52
-
53
- // wasn't a literal or symbolic name
54
- literalNames[i] = "";
55
- symbolicNames[i] = "";
56
48
  }
57
49
 
58
50
  return Vocabulary(literalNames, symbolicNames, tokenNames);
@@ -14,9 +14,6 @@ namespace dfa {
14
14
  /// interface.
15
15
  class ANTLR4CPP_PUBLIC Vocabulary {
16
16
  public:
17
- Vocabulary(Vocabulary const&) = default;
18
- virtual ~Vocabulary();
19
-
20
17
  /// Gets an empty <seealso cref="Vocabulary"/> instance.
21
18
  ///
22
19
  /// <para>
@@ -26,6 +23,8 @@ namespace dfa {
26
23
  static const Vocabulary EMPTY_VOCABULARY;
27
24
 
28
25
  Vocabulary() {}
26
+ Vocabulary(Vocabulary const&) = default;
27
+ virtual ~Vocabulary();
29
28
 
30
29
  /// <summary>
31
30
  /// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified
@@ -8,7 +8,6 @@
8
8
  #include <algorithm>
9
9
  #include <assert.h>
10
10
  #include <atomic>
11
- #include <codecvt>
12
11
  #include <chrono>
13
12
  #include <fstream>
14
13
  #include <iostream>
@@ -37,6 +36,10 @@
37
36
  #include <condition_variable>
38
37
  #include <functional>
39
38
 
39
+ #ifndef USE_UTF8_INSTEAD_OF_CODECVT
40
+ #include <codecvt>
41
+ #endif
42
+
40
43
  // Defines for the Guid class and other platform dependent stuff.
41
44
  #ifdef _WIN32
42
45
  #ifdef _MSC_VER
@@ -183,7 +183,7 @@ std::string ATN::toString() const {
183
183
  ss << "states (" << states.size() << ") {" << std::endl;
184
184
 
185
185
  size_t index = 0;
186
- for (auto state : states) {
186
+ for (auto *state : states) {
187
187
  if (state == nullptr) {
188
188
  ss << " " << index++ << ": nul" << std::endl;
189
189
  } else {
@@ -193,7 +193,7 @@ std::string ATN::toString() const {
193
193
  }
194
194
 
195
195
  index = 0;
196
- for (auto state : decisionToState) {
196
+ for (auto *state : decisionToState) {
197
197
  if (state == nullptr) {
198
198
  ss << " " << index++ << ": nul" << std::endl;
199
199
  } else {
@@ -12,7 +12,13 @@ namespace atn {
12
12
 
13
13
  class ANTLR4CPP_PUBLIC ATN {
14
14
  public:
15
- static const size_t INVALID_ALT_NUMBER = 0;
15
+ #if __cplusplus >= 201703L
16
+ static constexpr size_t INVALID_ALT_NUMBER = 0;
17
+ #else
18
+ enum : size_t {
19
+ INVALID_ALT_NUMBER = 0,
20
+ };
21
+ #endif
16
22
 
17
23
  /// Used for runtime deserialization of ATNs from strings.
18
24
  ATN();
@@ -11,8 +11,6 @@
11
11
 
12
12
  using namespace antlr4::atn;
13
13
 
14
- const size_t ATNConfig::SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
15
-
16
14
  ATNConfig::ATNConfig(ATNState *state_, size_t alt_, Ref<PredictionContext> const& context_)
17
15
  : ATNConfig(state_, alt_, context_, SemanticContext::NONE) {
18
16
  }
@@ -114,7 +114,13 @@ namespace atn {
114
114
  * {@link #isPrecedenceFilterSuppressed} property as a bit within the
115
115
  * existing {@link #reachesIntoOuterContext} field.
116
116
  */
117
- static const size_t SUPPRESS_PRECEDENCE_FILTER;
117
+ #if __cplusplus >= 201703L
118
+ static constexpr size_t SUPPRESS_PRECEDENCE_FILTER = 0x40000000;
119
+ #else
120
+ enum : size_t {
121
+ SUPPRESS_PRECEDENCE_FILTER = 0x40000000,
122
+ };
123
+ #endif
118
124
  };
119
125
 
120
126
  } // namespace atn
@@ -139,7 +145,7 @@ namespace std {
139
145
  size_t operator() (const std::vector<Ref<ATNConfig>> &vector) const
140
146
  {
141
147
  std::size_t seed = 0;
142
- for (auto &config : vector) {
148
+ for (const auto &config : vector) {
143
149
  seed ^= config->hashCode() + 0x9e3779b9 + (seed << 6) + (seed >> 2);
144
150
  }
145
151
  return seed;
@@ -57,8 +57,6 @@ using namespace antlr4;
57
57
  using namespace antlr4::atn;
58
58
  using namespace antlrcpp;
59
59
 
60
- const size_t ATNDeserializer::SERIALIZED_VERSION = 3;
61
-
62
60
  namespace {
63
61
 
64
62
  uint32_t deserializeInt32(const std::vector<uint16_t>& data, size_t offset) {
@@ -13,7 +13,13 @@ namespace atn {
13
13
 
14
14
  class ANTLR4CPP_PUBLIC ATNDeserializer {
15
15
  public:
16
- static const size_t SERIALIZED_VERSION;
16
+ #if __cplusplus >= 201703L
17
+ static constexpr size_t SERIALIZED_VERSION = 3;
18
+ #else
19
+ enum : size_t {
20
+ SERIALIZED_VERSION = 3,
21
+ };
22
+ #endif
17
23
 
18
24
  /// This is the current serialized UUID.
19
25
  // ml: defined as function to avoid the “static initialization order fiasco”.
@@ -166,7 +166,7 @@ std::vector<size_t> ATNSerializer::serialize() {
166
166
  }
167
167
 
168
168
  data.push_back(containsEof ? 1 : 0);
169
- for (auto &interval : set.getIntervals()) {
169
+ for (const auto &interval : set.getIntervals()) {
170
170
  if (interval.a == -1) {
171
171
  if (interval.b == -1) {
172
172
  continue;
@@ -17,7 +17,7 @@ ATNState::ATNState() {
17
17
  }
18
18
 
19
19
  ATNState::~ATNState() {
20
- for (auto transition : transitions) {
20
+ for (auto *transition : transitions) {
21
21
  delete transition;
22
22
  }
23
23
  }
@@ -81,8 +81,15 @@ namespace atn {
81
81
 
82
82
  ATNState& operator=(ATNState const&) = delete;
83
83
 
84
- static const size_t INITIAL_NUM_TRANSITIONS = 4;
85
- static const size_t INVALID_STATE_NUMBER = static_cast<size_t>(-1); // std::numeric_limits<size_t>::max();
84
+ #if __cplusplus >= 201703L
85
+ static constexpr size_t INITIAL_NUM_TRANSITIONS = 4;
86
+ static constexpr size_t INVALID_STATE_NUMBER = std::numeric_limits<size_t>::max();
87
+ #else
88
+ enum : size_t {
89
+ INITIAL_NUM_TRANSITIONS = 4,
90
+ INVALID_STATE_NUMBER = static_cast<size_t>(-1), // std::numeric_limits<size_t>::max(); doesn't work in VS 2013
91
+ };
92
+ #endif
86
93
 
87
94
  enum {
88
95
  ATN_INVALID_TYPE = 0,
@@ -100,18 +100,16 @@ void LL1Analyzer::_LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext>
100
100
  }
101
101
 
102
102
  if (ctx != PredictionContext::EMPTY) {
103
- // run thru all possible stack tops in ctx
103
+ bool removed = calledRuleStack.test(s->ruleIndex);
104
+ calledRuleStack[s->ruleIndex] = false;
105
+ auto onExit = finally([removed, &calledRuleStack, s] {
106
+ if (removed) {
107
+ calledRuleStack.set(s->ruleIndex);
108
+ }
109
+ });
110
+ // run thru all possible stack tops in ctx
104
111
  for (size_t i = 0; i < ctx->size(); i++) {
105
112
  ATNState *returnState = _atn.states[ctx->getReturnState(i)];
106
-
107
- bool removed = calledRuleStack.test(returnState->ruleIndex);
108
- auto onExit = finally([removed, &calledRuleStack, returnState] {
109
- if (removed) {
110
- calledRuleStack.set(returnState->ruleIndex);
111
- }
112
- });
113
-
114
- calledRuleStack[returnState->ruleIndex] = false;
115
113
  _LOOK(returnState, stopState, ctx->getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
116
114
  }
117
115
  return;
@@ -17,7 +17,13 @@ namespace atn {
17
17
  public:
18
18
  /// Special value added to the lookahead sets to indicate that we hit
19
19
  /// a predicate during analysis if {@code seeThruPreds==false}.
20
- static const size_t HIT_PRED = Token::INVALID_TYPE;
20
+ #if __cplusplus >= 201703L
21
+ static constexpr size_t HIT_PRED = Token::INVALID_TYPE;
22
+ #else
23
+ enum : size_t {
24
+ HIT_PRED = Token::INVALID_TYPE,
25
+ };
26
+ #endif
21
27
 
22
28
  const atn::ATN &_atn;
23
29