Logic for [] was too simple, remove it for time being
This commit is contained in:
parent
fdb5797ee0
commit
2b74819b15
11
regex.py
11
regex.py
|
@ -47,13 +47,9 @@ class Alternation:
|
|||
return 'Alternation(%s)' % ', '.join(map(repr, self.elements))
|
||||
|
||||
def __str__(self):
|
||||
if all(type(i) == Literal and i.single_char for i in self.elements):
|
||||
# Special case: [abc]
|
||||
return '[%s]' % ''.join(map(str, self.elements))
|
||||
else:
|
||||
# Nothing binds looser than alternation, so just
|
||||
# pass everything through as-is
|
||||
return '|'.join(map(str, self.elements))
|
||||
# Nothing binds looser than alternation, so just pass
|
||||
# everything through as-is
|
||||
return '|'.join(map(str, self.elements))
|
||||
|
||||
class Star:
|
||||
def __init__(self, element):
|
||||
|
@ -75,6 +71,7 @@ def lit(text):
|
|||
return Literal(text)
|
||||
|
||||
def concat(*elements):
|
||||
# TODO: drop literals that are just ''
|
||||
flattened = []
|
||||
for element in elements:
|
||||
if type(element) == Concatenation:
|
||||
|
|
Loading…
Reference in New Issue