diff --git a/core/value.asdl b/core/value.asdl index 0720760b02..4a7ed68553 100644 --- a/core/value.asdl +++ b/core/value.asdl @@ -10,6 +10,7 @@ module value re proc_sig LiteralBlock Func NameType + EggexFlag } use core runtime { @@ -72,8 +73,10 @@ module value # unevaluated: Eggex, Expr, Template, Command/Block # callable, in separate namespaces: Func, BoundFunc, Proc + # expr is spliced # / d+; ignorecase / -> '[[:digit:]]+' REG_ICASE - | Eggex(re expr, List[str] flags, str? as_ere, int ere_flags, + | Eggex(re spliced, List[EggexFlag] normalized_flags, str? as_ere, + int ere_flags, # inner ? is because some groups are not named # outer ? because it's not set until ERE translation is done List[NameType?]? name_types) diff --git a/ysh/expr_eval.py b/ysh/expr_eval.py index 49d0e673f2..733bc987f3 100644 --- a/ysh/expr_eval.py +++ b/ysh/expr_eval.py @@ -35,6 +35,7 @@ CharCode, ArgList, Eggex, + EggexFlag, ) from _devbuild.gen.runtime_asdl import ( coerced_e, @@ -53,7 +54,7 @@ from core import ui from core import vm from frontend import consts -from frontend import lexer +#from frontend import lexer from frontend import match from frontend import location from frontend import typed_args @@ -1323,7 +1324,7 @@ def _EvalRegex(self, node): val = cast(value.Eggex, UP_val) # TODO: warn about flags that don't match # This check will be transitive - to_splice = val.expr + to_splice = val.spliced else: raise error.TypeErr( @@ -1351,7 +1352,7 @@ def EvalEggex(self, node): # - or can the root override flags? Probably not spliced = self._EvalRegex(node.regex) #flags = [lexer.TokenVal(tok) for tok in node.flags] - flags = [] # type: List[str] + flags = [] # type: List[EggexFlag] return value.Eggex(spliced, flags, None, 0, None) diff --git a/ysh/regex_translate.py b/ysh/regex_translate.py index d6b4a48981..9c55a85a70 100644 --- a/ysh/regex_translate.py +++ b/ysh/regex_translate.py @@ -337,7 +337,7 @@ def AsPosixEre(eggex): parts = [] # type: List[str] name_types = [] # type: List[NameType] - _AsPosixEre(eggex.expr, parts, name_types) + _AsPosixEre(eggex.spliced, parts, name_types) #names = [n.name.tval for n in name_types] #log('names %s', names)