Skip to content

Commit

Permalink
[eggex refactor] Rename fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Dec 12, 2023
1 parent dcb91ad commit b87c12e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion core/value.asdl
Expand Up @@ -10,6 +10,7 @@ module value
re proc_sig
LiteralBlock Func
NameType
EggexFlag
}

use core runtime {
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions ysh/expr_eval.py
Expand Up @@ -35,6 +35,7 @@
CharCode,
ArgList,
Eggex,
EggexFlag,
)
from _devbuild.gen.runtime_asdl import (
coerced_e,
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion ysh/regex_translate.py
Expand Up @@ -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)
Expand Down

0 comments on commit b87c12e

Please sign in to comment.