Logic for [] was too simple, remove it for time being

This commit is contained in:
Juhani Krekelä 2019-05-31 14:06:39 +03:00
parent fdb5797ee0
commit 2b74819b15
1 changed files with 4 additions and 7 deletions

View File

@ -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: