Make \h and \H character class escapes

This commit is contained in:
Nick Rolfe
2021-06-25 12:27:39 +01:00
parent a5dff79e51
commit a77e7761fd
2 changed files with 5 additions and 10 deletions

View File

@@ -399,12 +399,7 @@ class RegExpEscape extends RegExpNormalChar {
* ```
*/
class RegExpCharacterClassEscape extends RegExpEscape {
// string value;
RegExpCharacterClassEscape() {
// value = re.getText().substring(start + 1, end) and
// value in ["d", "D", "s", "S", "w", "W"]
this.getValue() in ["d", "D", "s", "S", "w", "W"]
}
RegExpCharacterClassEscape() { this.getValue() in ["d", "D", "s", "S", "w", "W", "h", "H"] }
/** Gets the name of the character class; for example, `w` for `\w`. */
// override string getValue() { result = value }

View File

@@ -216,7 +216,7 @@ regexp.rb:
# 33| [RegExpCharacterClassEscape] \d
# 34| [RegExpConstant, RegExpEscape] \h
# 34| [RegExpCharacterClassEscape] \h
# 37| [RegExpConstant, RegExpNormalChar] f
@@ -291,8 +291,8 @@ regexp.rb:
#-----| 1 -> [RegExpCharacterClassEscape] \D
# 34| [RegExpSequence] \h\H
#-----| 0 -> [RegExpConstant, RegExpEscape] \h
#-----| 1 -> [RegExpConstant, RegExpEscape] \H
#-----| 0 -> [RegExpCharacterClassEscape] \h
#-----| 1 -> [RegExpCharacterClassEscape] \H
# 37| [RegExpSequence] (foo)*bar
#-----| 0 -> [RegExpStar] (foo)*
@@ -388,7 +388,7 @@ regexp.rb:
# 33| [RegExpCharacterClassEscape] \D
# 34| [RegExpConstant, RegExpEscape] \H
# 34| [RegExpCharacterClassEscape] \H
# 37| [RegExpConstant, RegExpNormalChar] o