MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / parse_regex

Function parse_regex

2018/src/20.py:21–32  ·  view source on GitHub ↗
(s: str, i: int)

Source from the content-addressed store, hash-verified

19 return i+1, (RegexType.OR, regexes)
20
21def parse_regex(s: str, i: int) -> tuple[int,Regex]:
22 r = []
23 while i < len(s) and s[i] not in "|)":
24 if s[i] == '(':
25 i,r1 = parse_regexor(s,i+1)
26 else:
27 iprev = i
28 while i < len(s) and s[i] in "NSEW":
29 i += 1
30 r1 = (RegexType.SIMPLE, s[iprev:i])
31 r.append(r1)
32 return i, (RegexType.LIST, r)
33
34def apply_regex(m: Graph, regex: Regex, coords: set[tuple[int,int]]) -> set[tuple[int,int]]:
35 match regex[0]:

Callers 2

parse_regexorFunction · 0.85
mainFunction · 0.85

Calls 1

parse_regexorFunction · 0.85

Tested by

no test coverage detected