expressir 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -38,8 +38,15 @@ namespace atn {
38
38
 
39
39
 
40
40
  public:
41
- static const size_t MIN_DFA_EDGE = 0;
42
- static const size_t MAX_DFA_EDGE = 127; // forces unicode to stay in ATN
41
+ #if __cplusplus >= 201703L
42
+ static constexpr size_t MIN_DFA_EDGE = 0;
43
+ static constexpr size_t MAX_DFA_EDGE = 127; // forces unicode to stay in ATN
44
+ #else
45
+ enum : size_t {
46
+ MIN_DFA_EDGE = 0,
47
+ MAX_DFA_EDGE = 127, // forces unicode to stay in ATN
48
+ };
49
+ #endif
43
50
 
44
51
  protected:
45
52
  /// <summary>
@@ -774,7 +774,7 @@ std::pair<ATNConfigSet *, ATNConfigSet *> ParserATNSimulator::splitAccordingToSe
774
774
  BitSet ParserATNSimulator::evalSemanticContext(std::vector<dfa::DFAState::PredPrediction*> predPredictions,
775
775
  ParserRuleContext *outerContext, bool complete) {
776
776
  BitSet predictions;
777
- for (auto prediction : predPredictions) {
777
+ for (auto *prediction : predPredictions) {
778
778
  if (prediction->pred == SemanticContext::NONE) {
779
779
  predictions.set(prediction->alt);
780
780
  if (!complete) {
@@ -1348,7 +1348,9 @@ Parser* ParserATNSimulator::getParser() {
1348
1348
  return parser;
1349
1349
  }
1350
1350
 
1351
- #pragma warning (disable:4996) // 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead.
1351
+ #ifdef _MSC_VER
1352
+ #pragma warning (disable:4996) // 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead.
1353
+ #endif
1352
1354
 
1353
1355
  bool ParserATNSimulator::getLrLoopSetting() {
1354
1356
  char *var = std::getenv("TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT");
@@ -1358,7 +1360,9 @@ bool ParserATNSimulator::getLrLoopSetting() {
1358
1360
  return value == "true" || value == "1";
1359
1361
  }
1360
1362
 
1363
+ #ifdef _MSC_VER
1361
1364
  #pragma warning (default:4996)
1365
+ #endif
1362
1366
 
1363
1367
  void ParserATNSimulator::InitializeInstanceFields() {
1364
1368
  _mode = PredictionMode::LL;
@@ -30,10 +30,22 @@ namespace atn {
30
30
  // ml: originally Integer.MAX_VALUE, which would be -1 for us, but this is already used in places where
31
31
  // -1 is converted to unsigned, so we use a different value here. Any value does the job provided it doesn't
32
32
  // conflict with real return states.
33
- static const size_t EMPTY_RETURN_STATE = static_cast<size_t>(-10); // std::numeric_limits<size_t>::max() - 9;
33
+ #if __cplusplus >= 201703L
34
+ static constexpr size_t EMPTY_RETURN_STATE = std::numeric_limits<size_t>::max() - 9;
35
+ #else
36
+ enum : size_t {
37
+ EMPTY_RETURN_STATE = static_cast<size_t>(-10), // std::numeric_limits<size_t>::max() - 9; doesn't work in VS 2013
38
+ };
39
+ #endif
34
40
 
35
41
  private:
36
- static const size_t INITIAL_HASH = 1;
42
+ #if __cplusplus >= 201703L
43
+ static constexpr size_t INITIAL_HASH = 1;
44
+ #else
45
+ enum : size_t {
46
+ INITIAL_HASH = 1,
47
+ };
48
+ #endif
37
49
 
38
50
  public:
39
51
  static size_t globalNodeCount;
@@ -46,7 +46,7 @@ DFA::DFA(DFA &&other) : atnStartState(other.atnStartState), decision(other.decis
46
46
 
47
47
  DFA::~DFA() {
48
48
  bool s0InList = (s0 == nullptr);
49
- for (auto state : states) {
49
+ for (auto *state : states) {
50
50
  if (state == s0)
51
51
  s0InList = true;
52
52
  delete state;
@@ -88,7 +88,7 @@ void DFA::setPrecedenceStartState(int precedence, DFAState *startState, SingleWr
88
88
 
89
89
  std::vector<DFAState *> DFA::getStates() const {
90
90
  std::vector<DFAState *> result;
91
- for (auto state : states)
91
+ for (auto *state : states)
92
92
  result.push_back(state);
93
93
 
94
94
  std::sort(result.begin(), result.end(), [](DFAState *o1, DFAState *o2) -> bool {
@@ -27,7 +27,7 @@ std::string DFASerializer::toString() const {
27
27
 
28
28
  std::stringstream ss;
29
29
  std::vector<DFAState *> states = _dfa->getStates();
30
- for (auto s : states) {
30
+ for (auto *s : states) {
31
31
  for (size_t i = 0; i < s->edges.size(); i++) {
32
32
  DFAState *t = s->edges[i];
33
33
  if (t != nullptr && t->stateNumber != INT32_MAX) {
@@ -42,7 +42,7 @@ DFAState::DFAState(std::unique_ptr<ATNConfigSet> configs_) : DFAState() {
42
42
  }
43
43
 
44
44
  DFAState::~DFAState() {
45
- for (auto predicate : predicates) {
45
+ for (auto *predicate : predicates) {
46
46
  delete predicate;
47
47
  }
48
48
  }
@@ -112,7 +112,7 @@ void IntervalSet::add(const Interval &addition) {
112
112
 
113
113
  IntervalSet IntervalSet::Or(const std::vector<IntervalSet> &sets) {
114
114
  IntervalSet result;
115
- for (auto &s : sets) {
115
+ for (const auto &s : sets) {
116
116
  result.addAll(s);
117
117
  }
118
118
  return result;
@@ -271,7 +271,7 @@ bool IntervalSet::contains(ssize_t el) const {
271
271
  if (el < _intervals[0].a) // list is sorted and el is before first interval; not here
272
272
  return false;
273
273
 
274
- for (auto &interval : _intervals) {
274
+ for (const auto &interval : _intervals) {
275
275
  if (el >= interval.a && el <= interval.b) {
276
276
  return true; // found in this interval
277
277
  }
@@ -315,7 +315,7 @@ std::vector<Interval> const& IntervalSet::getIntervals() const {
315
315
 
316
316
  size_t IntervalSet::hashCode() const {
317
317
  size_t hash = MurmurHash::initialize();
318
- for (auto &interval : _intervals) {
318
+ for (const auto &interval : _intervals) {
319
319
  hash = MurmurHash::update(hash, interval.a);
320
320
  hash = MurmurHash::update(hash, interval.b);
321
321
  }
@@ -349,7 +349,7 @@ std::string IntervalSet::toString(bool elemAreChar) const {
349
349
  }
350
350
 
351
351
  bool firstEntry = true;
352
- for (auto &interval : _intervals) {
352
+ for (const auto &interval : _intervals) {
353
353
  if (!firstEntry)
354
354
  ss << ", ";
355
355
  firstEntry = false;
@@ -395,7 +395,7 @@ std::string IntervalSet::toString(const dfa::Vocabulary &vocabulary) const {
395
395
  }
396
396
 
397
397
  bool firstEntry = true;
398
- for (auto &interval : _intervals) {
398
+ for (const auto &interval : _intervals) {
399
399
  if (!firstEntry)
400
400
  ss << ", ";
401
401
  firstEntry = false;
@@ -436,7 +436,7 @@ std::string IntervalSet::elementName(const dfa::Vocabulary &vocabulary, ssize_t
436
436
 
437
437
  size_t IntervalSet::size() const {
438
438
  size_t result = 0;
439
- for (auto &interval : _intervals) {
439
+ for (const auto &interval : _intervals) {
440
440
  result += size_t(interval.b - interval.a + 1);
441
441
  }
442
442
  return result;
@@ -444,7 +444,7 @@ size_t IntervalSet::size() const {
444
444
 
445
445
  std::vector<ssize_t> IntervalSet::toList() const {
446
446
  std::vector<ssize_t> result;
447
- for (auto &interval : _intervals) {
447
+ for (const auto &interval : _intervals) {
448
448
  ssize_t a = interval.a;
449
449
  ssize_t b = interval.b;
450
450
  for (ssize_t v = a; v <= b; v++) {
@@ -456,7 +456,7 @@ std::vector<ssize_t> IntervalSet::toList() const {
456
456
 
457
457
  std::set<ssize_t> IntervalSet::toSet() const {
458
458
  std::set<ssize_t> result;
459
- for (auto &interval : _intervals) {
459
+ for (const auto &interval : _intervals) {
460
460
  ssize_t a = interval.a;
461
461
  ssize_t b = interval.b;
462
462
  for (ssize_t v = a; v <= b; v++) {
@@ -468,7 +468,7 @@ std::set<ssize_t> IntervalSet::toSet() const {
468
468
 
469
469
  ssize_t IntervalSet::get(size_t i) const {
470
470
  size_t index = 0;
471
- for (auto &interval : _intervals) {
471
+ for (const auto &interval : _intervals) {
472
472
  ssize_t a = interval.a;
473
473
  ssize_t b = interval.b;
474
474
  for (ssize_t v = a; v <= b; v++) {
@@ -13,7 +13,13 @@ namespace misc {
13
13
  class ANTLR4CPP_PUBLIC MurmurHash {
14
14
 
15
15
  private:
16
- static const size_t DEFAULT_SEED = 0;
16
+ #if __cplusplus >= 201703L
17
+ static constexpr size_t DEFAULT_SEED = 0;
18
+ #else
19
+ enum : size_t {
20
+ DEFAULT_SEED = 0,
21
+ };
22
+ #endif
17
23
 
18
24
  /// Initialize the hash using the default seed value.
19
25
  /// Returns the intermediate hash value.
@@ -79,7 +79,7 @@ struct ANTLR4CPP_PUBLIC Any
79
79
  if (_ptr == a._ptr)
80
80
  return *this;
81
81
 
82
- auto old_ptr = _ptr;
82
+ auto * old_ptr = _ptr;
83
83
  _ptr = a.clone();
84
84
 
85
85
  if (old_ptr)
@@ -16,7 +16,7 @@ std::string Arrays::listToString(const std::vector<std::string> &list, const std
16
16
  bool firstEntry = true;
17
17
 
18
18
  ss << '[';
19
- for (auto &entry : list) {
19
+ for (const auto &entry : list) {
20
20
  ss << entry;
21
21
  if (firstEntry) {
22
22
  ss << separator;
@@ -32,7 +32,7 @@ template <>
32
32
  std::string Arrays::toString(const std::vector<antlr4::tree::ParseTree*> &source) {
33
33
  std::string result = "[";
34
34
  bool firstEntry = true;
35
- for (auto value : source) {
35
+ for (auto *value : source) {
36
36
  result += value->toStringTree();
37
37
  if (firstEntry) {
38
38
  result += ", ";
@@ -46,7 +46,7 @@ namespace antlrcpp {
46
46
 
47
47
  case ' ':
48
48
  if (escapeSpaces) {
49
- result += "·";
49
+ result += "\u00B7";
50
50
  break;
51
51
  }
52
52
  // else fall through
@@ -20,16 +20,26 @@ void replaceAll(std::string& str, std::string const& from, std::string const& to
20
20
  }
21
21
 
22
22
  std::string ws2s(std::wstring const& wstr) {
23
+ #ifndef USE_UTF8_INSTEAD_OF_CODECVT
23
24
  std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
24
25
  std::string narrow = converter.to_bytes(wstr);
26
+ #else
27
+ std::string narrow;
28
+ utf8::utf32to8(wstr.begin(), wstr.end(), std::back_inserter(narrow));
29
+ #endif
25
30
 
26
31
  return narrow;
27
32
  }
28
33
 
29
34
  std::wstring s2ws(const std::string &str) {
35
+ #ifndef USE_UTF8_INSTEAD_OF_CODECVT
30
36
  std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
31
37
  std::wstring wide = converter.from_bytes(str);
32
-
38
+ #else
39
+ std::wstring wide;
40
+ utf8::utf8to32(str.begin(), str.end(), std::back_inserter(wide));
41
+ #endif
42
+
33
43
  return wide;
34
44
  }
35
45
 
@@ -7,43 +7,65 @@
7
7
 
8
8
  #include "antlr4-common.h"
9
9
 
10
+ #ifdef USE_UTF8_INSTEAD_OF_CODECVT
11
+ #include "utf8.h"
12
+ #endif
13
+
10
14
  namespace antlrcpp {
11
15
 
12
16
  // For all conversions utf8 <-> utf32.
17
+ // I wouldn't prefer wstring_convert because: according to
18
+ // https://en.cppreference.com/w/cpp/locale/wstring_convert,
19
+ // wstring_convert is deprecated in C++17.
20
+ // utfcpp (https://github.com/nemtrif/utfcpp) is a substitution.
21
+ #ifndef USE_UTF8_INSTEAD_OF_CODECVT
13
22
  // VS 2015 and VS 2017 have different bugs in std::codecvt_utf8<char32_t> (VS 2013 works fine).
14
- #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
15
- typedef std::wstring_convert<std::codecvt_utf8<__int32>, __int32> UTF32Converter;
16
- #else
17
- typedef std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> UTF32Converter;
23
+ #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
24
+ typedef std::wstring_convert<std::codecvt_utf8<__int32>, __int32> UTF32Converter;
25
+ #else
26
+ typedef std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> UTF32Converter;
27
+ #endif
18
28
  #endif
19
-
29
+
20
30
  // The conversion functions fails in VS2017, so we explicitly use a workaround.
21
31
  template<typename T>
22
32
  inline std::string utf32_to_utf8(T const& data)
23
33
  {
24
- // Don't make the converter static or we have to serialize access to it.
25
- thread_local UTF32Converter converter;
34
+ #ifndef USE_UTF8_INSTEAD_OF_CODECVT
35
+ // Don't make the converter static or we have to serialize access to it.
36
+ thread_local UTF32Converter converter;
26
37
 
27
- #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
28
- auto p = reinterpret_cast<const int32_t *>(data.data());
29
- return converter.to_bytes(p, p + data.size());
38
+ #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
39
+ const auto p = reinterpret_cast<const int32_t *>(data.data());
40
+ return converter.to_bytes(p, p + data.size());
41
+ #else
42
+ return converter.to_bytes(data);
43
+ #endif
30
44
  #else
31
- return converter.to_bytes(data);
45
+ std::string narrow;
46
+ utf8::utf32to8(data.begin(), data.end(), std::back_inserter(narrow));
47
+ return narrow;
32
48
  #endif
33
49
  }
34
50
 
35
51
  inline UTF32String utf8_to_utf32(const char* first, const char* last)
36
52
  {
37
- thread_local UTF32Converter converter;
53
+ #ifndef USE_UTF8_INSTEAD_OF_CODECVT
54
+ thread_local UTF32Converter converter;
38
55
 
39
- #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
40
- auto r = converter.from_bytes(first, last);
41
- i32string s = reinterpret_cast<const int32_t *>(r.data());
56
+ #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
57
+ auto r = converter.from_bytes(first, last);
58
+ i32string s = reinterpret_cast<const int32_t *>(r.data());
59
+ return s;
60
+ #else
61
+ std::u32string s = converter.from_bytes(first, last);
62
+ return s;
63
+ #endif
42
64
  #else
43
- std::u32string s = converter.from_bytes(first, last);
65
+ UTF32String wide;
66
+ utf8::utf8to32(first, last, std::back_inserter(wide));
67
+ return wide;
44
68
  #endif
45
-
46
- return s;
47
69
  }
48
70
 
49
71
  void replaceAll(std::string &str, std::string const& from, std::string const& to);
@@ -88,7 +88,7 @@ namespace tree {
88
88
  }
89
89
 
90
90
  void reset() {
91
- for (auto entry : _allocated)
91
+ for (auto * entry : _allocated)
92
92
  delete entry;
93
93
  _allocated.clear();
94
94
  }
@@ -15,15 +15,39 @@ namespace tree {
15
15
  static ParseTreeWalker &DEFAULT;
16
16
 
17
17
  virtual ~ParseTreeWalker();
18
-
18
+
19
+ /**
20
+ * <summary>
21
+ * Performs a walk on the given parse tree starting at the root and going down recursively
22
+ * with depth-first search. On each node, <seealso cref="ParseTreeWalker#enterRule"/> is called before
23
+ * recursively walking down into child nodes, then
24
+ * <seealso cref="ParseTreeWalker#exitRule"/> is called after the recursive call to wind up.
25
+ * </summary>
26
+ * <param name='listener'> The listener used by the walker to process grammar rules </param>
27
+ * <param name='t'> The parse tree to be walked on </param>
28
+ */
19
29
  virtual void walk(ParseTreeListener *listener, ParseTree *t) const;
20
30
 
21
31
  protected:
22
- /// The discovery of a rule node, involves sending two events: the generic
23
- /// <seealso cref="ParseTreeListener#enterEveryRule"/> and a
24
- /// <seealso cref="RuleContext"/>-specific event. First we trigger the generic and then
25
- /// the rule specific. We do them in reverse order upon finishing the node.
32
+
33
+ /**
34
+ * <summary>
35
+ * Enters a grammar rule by first triggering the generic event <seealso cref="ParseTreeListener#enterEveryRule"/>
36
+ * then by triggering the event specific to the given parse tree node
37
+ * </summary>
38
+ * <param name='listener'> The listener responding to the trigger events </param>
39
+ * <param name='r'> The grammar rule containing the rule context </param>
40
+ */
26
41
  virtual void enterRule(ParseTreeListener *listener, ParseTree *r) const;
42
+
43
+ /**
44
+ * <summary>
45
+ * Exits a grammar rule by first triggering the event specific to the given parse tree node
46
+ * then by triggering the generic event <seealso cref="ParseTreeListener#exitEveryRule"/>
47
+ * </summary>
48
+ * <param name='listener'> The listener responding to the trigger events </param>
49
+ * <param name='r'> The grammar rule containing the rule context </param>
50
+ */
27
51
  virtual void exitRule(ParseTreeListener *listener, ParseTree *r) const;
28
52
  };
29
53
 
@@ -192,7 +192,7 @@ std::vector<ParseTree *> Trees::getDescendants(ParseTree *t) {
192
192
  std::size_t n = t->children.size();
193
193
  for (size_t i = 0 ; i < n ; i++) {
194
194
  auto descentants = getDescendants(t->children[i]);
195
- for (auto entry: descentants) {
195
+ for (auto *entry: descentants) {
196
196
  nodes.push_back(entry);
197
197
  }
198
198
  }
@@ -37,7 +37,7 @@ std::vector<ParseTreeMatch> ParseTreePattern::findAll(ParseTree *tree, const std
37
37
  xpath::XPath finder(_matcher->getParser(), xpath);
38
38
  std::vector<ParseTree *> subtrees = finder.evaluate(tree);
39
39
  std::vector<ParseTreeMatch> matches;
40
- for (auto t : subtrees) {
40
+ for (auto *t : subtrees) {
41
41
  ParseTreeMatch aMatch = match(t);
42
42
  if (aMatch.succeeded()) {
43
43
  matches.push_back(aMatch);
@@ -137,7 +137,7 @@ std::vector<ParseTree *> XPath::evaluate(ParseTree *t) {
137
137
 
138
138
  while (i < elements.size()) {
139
139
  std::vector<ParseTree *> next;
140
- for (auto node : work) {
140
+ for (auto *node : work) {
141
141
  if (!node->children.empty()) {
142
142
  // only try to match next element if it has children
143
143
  // e.g., //func/*/stat might have a token node for which
@@ -18,7 +18,7 @@ XPathRuleElement::XPathRuleElement(const std::string &ruleName, size_t ruleIndex
18
18
  std::vector<ParseTree *> XPathRuleElement::evaluate(ParseTree *t) {
19
19
  // return all children of t that match nodeName
20
20
  std::vector<ParseTree *> nodes;
21
- for (auto c : t->children) {
21
+ for (auto *c : t->children) {
22
22
  if (antlrcpp::is<ParserRuleContext *>(c)) {
23
23
  ParserRuleContext *ctx = dynamic_cast<ParserRuleContext *>(c);
24
24
  if ((ctx->getRuleIndex() == _ruleIndex && !_invert) || (ctx->getRuleIndex() != _ruleIndex && _invert)) {
@@ -21,7 +21,7 @@ XPathTokenElement::XPathTokenElement(const std::string &tokenName, size_t tokenT
21
21
  std::vector<ParseTree *> XPathTokenElement::evaluate(ParseTree *t) {
22
22
  // return all children of t that match nodeName
23
23
  std::vector<ParseTree *> nodes;
24
- for (auto c : t->children) {
24
+ for (auto *c : t->children) {
25
25
  if (antlrcpp::is<TerminalNode *>(c)) {
26
26
  TerminalNode *tnode = dynamic_cast<TerminalNode *>(c);
27
27
  if ((tnode->getSymbol()->getType() == _tokenType && !_invert) || (tnode->getSymbol()->getType() != _tokenType && _invert)) {