22
33import static info .codesaway .bex .matching .BEXGroupMatchSetting .DEFAULT ;
44import static info .codesaway .bex .matching .BEXGroupMatchSetting .STOP_WHEN_VALID ;
5- import static info .codesaway .bex .matching . BEXMatchingStateOption . MISMATCHED_DELIMITERS ;
6- import static info .codesaway .bex .matching . BEXMatchingUtilities . hasNextChar ;
7- import static info .codesaway .bex .matching . BEXMatchingUtilities . hasText ;
8- import static info .codesaway .bex .matching . BEXMatchingUtilities . isWordCharacter ;
9- import static info .codesaway .bex .matching . BEXMatchingUtilities . nextChar ;
10- import static info .codesaway .bex .matching . BEXMatchingUtilities . parseJavaTextStates ;
5+ import static info .codesaway .bex .parsing . BEXParsingUtilities . hasNextChar ;
6+ import static info .codesaway .bex .parsing . BEXParsingUtilities . hasText ;
7+ import static info .codesaway .bex .parsing . BEXParsingUtilities . isWordCharacter ;
8+ import static info .codesaway .bex .parsing . BEXParsingUtilities . nextChar ;
9+ import static info .codesaway .bex .parsing . BEXParsingUtilities . parseJavaTextStates ;
10+ import static info .codesaway .bex .parsing . BEXParsingState . MISMATCHED_DELIMITERS ;
1111import static info .codesaway .bex .util .BEXUtilities .entry ;
1212import static info .codesaway .bex .util .BEXUtilities .getSubstring ;
1313
3434import info .codesaway .bex .IntBEXRange ;
3535import info .codesaway .bex .IntRange ;
3636import info .codesaway .bex .MutableIntBEXPair ;
37+ import info .codesaway .bex .parsing .BEXParsingLanguage ;
38+ import info .codesaway .bex .parsing .BEXString ;
39+ import info .codesaway .bex .parsing .ParsingDelimiterResult ;
40+ import info .codesaway .bex .parsing .ParsingDelimiterState ;
41+ import info .codesaway .bex .parsing .ParsingLanguage ;
42+ import info .codesaway .bex .parsing .ParsingState ;
3743import info .codesaway .util .regex .Matcher ;
3844import info .codesaway .util .regex .Pattern ;
3945
@@ -55,12 +61,12 @@ public final class BEXMatcher implements BEXMatchResult {
5561 private CharSequence text ;
5662
5763 // TODO: should I add a public getter for language?
58- private MatchingLanguage language ;
64+ private ParsingLanguage language ;
5965
6066 /**
6167 * Map from range to text state
6268 */
63- private ImmutableIntRangeMap <MatchingStateOption > textStateMap ;
69+ private ImmutableIntRangeMap <ParsingState > textStateMap ;
6470
6571 /**
6672 * Offset used when resolving indexes in textStateMap (allows sharing textStateMap such as in BEXString)
@@ -85,11 +91,11 @@ public final class BEXMatcher implements BEXMatchResult {
8591 private Map <String , List <IntBEXRange >> multipleValuesMap = Collections .emptyMap ();
8692
8793 BEXMatcher (final BEXPattern parent , final CharSequence text ) {
88- this (parent , text , BEXMatchingLanguage .JAVA , parseJavaTextStates (text ), 0 );
94+ this (parent , text , BEXParsingLanguage .JAVA , parseJavaTextStates (text ), 0 );
8995 }
9096
91- BEXMatcher (final BEXPattern parent , final CharSequence text , final MatchingLanguage language ,
92- final ImmutableIntRangeMap <MatchingStateOption > textStateMap , final int offset ) {
97+ BEXMatcher (final BEXPattern parent , final CharSequence text , final ParsingLanguage language ,
98+ final ImmutableIntRangeMap <ParsingState > textStateMap , final int offset ) {
9399 this .parentPattern = parent ;
94100 this .text = text ;
95101 this .language = language ;
@@ -309,7 +315,7 @@ private boolean match(final int from) {
309315 if (i == 0 ) {
310316 // TODO: check that state is valid
311317 int startWithOffset = matcher .start () + this .offset ;
312- Entry <IntRange , MatchingStateOption > entry = this .textStateMap .getEntry (startWithOffset );
318+ Entry <IntRange , ParsingState > entry = this .textStateMap .getEntry (startWithOffset );
313319
314320 boolean isValid ;
315321 if (entry != null && startWithOffset != entry .getKey ().getStart ()
@@ -340,7 +346,7 @@ private boolean match(final int from) {
340346 }
341347
342348 int startWithOffset = start + this .offset ;
343- Entry <IntRange , MatchingStateOption > entry = this .textStateMap .getEntry (startWithOffset );
349+ Entry <IntRange , ParsingState > entry = this .textStateMap .getEntry (startWithOffset );
344350
345351 BEXMatchingState initialState ;
346352 if (entry != null && startWithOffset != entry .getKey ().getStart ()
@@ -558,7 +564,7 @@ private BEXMatchingState search(final int start, final int end,
558564 // TODO: how to handle multiple levels? Currently, only get top most level
559565 // For example, JSP expression within String literal gets JSP expression, but doesn't know about String literal outside
560566
561- MatchingStateOption stateOption = null ;
567+ ParsingState stateOption = null ;
562568
563569 if (state != null ) {
564570 delimiters .addAll (state .getDelimiters ());
@@ -568,7 +574,7 @@ private BEXMatchingState search(final int start, final int end,
568574
569575 for (int i = start ; i < end ; i ++) {
570576 int indexWithOffset = i + this .offset ;
571- Entry <IntRange , MatchingStateOption > entry = this .textStateMap .getEntry (indexWithOffset );
577+ Entry <IntRange , ParsingState > entry = this .textStateMap .getEntry (indexWithOffset );
572578
573579 if (entry != null && !entry .getValue ().isCode ()) {
574580 // Has a state option
@@ -589,15 +595,15 @@ private BEXMatchingState search(final int start, final int end,
589595 delimiters .add (startDelimiter .get ());
590596 i += startDelimiter .get ().getLeft ().length () - 1 ;
591597 } else {
592- MatchingDelimiterState delimiterState = this .language .findEndDelimiter (delimiters .peekLast (),
598+ ParsingDelimiterState delimiterState = this .language .findEndDelimiter (delimiters .peekLast (),
593599 this .text , i , settings );
594- MatchingDelimiterResult result = delimiterState .getResult ();
600+ ParsingDelimiterResult result = delimiterState .getResult ();
595601
596- if (result == MatchingDelimiterResult .MISMATCHED ) {
602+ if (result == ParsingDelimiterResult .MISMATCHED ) {
597603 // XXX: should position be after the mismatch - so can try again at this point
598604 return new BEXMatchingState (i + delimiterState .getDelimiter ().length (), delimiters ,
599605 MISMATCHED_DELIMITERS );
600- } else if (result == MatchingDelimiterResult .FOUND ) {
606+ } else if (result == ParsingDelimiterResult .FOUND ) {
601607 // Remove last delimiter
602608 delimiters .removeLast ();
603609
@@ -770,7 +776,7 @@ public BEXMatcher reset() {
770776 */
771777 public BEXMatcher reset (final CharSequence input ) {
772778 this .text = input ;
773- this .language = BEXMatchingLanguage .JAVA ;
779+ this .language = BEXParsingLanguage .JAVA ;
774780 this .textStateMap = parseJavaTextStates (input );
775781 this .offset = 0 ;
776782 return this .reset ();
0 commit comments