Beispiel #1
0
def newlines(number: int) -> Element:
    return ComplexElement('line_ending').add(
        PrimitiveElement('newlines', number))
Beispiel #2
0
def bracket_argument(bracket_size: int, data: str) -> Element:
    bracket_part = '=' * bracket_size
    return ComplexElement('bracket_argument') \
        .add(PrimitiveElement('bracket_start', f'[{bracket_part}[')) \
        .add(PrimitiveElement('bracket_argument_content', data)) \
        .add(PrimitiveElement('bracket_end', f']{bracket_part}]'))
Beispiel #3
0
def line_ending(comment, newlines_number):
    return ComplexElement('line_ending') \
        .add(PrimitiveElement('line_comment', comment)) \
        .add(PrimitiveElement('newlines', newlines_number))
Beispiel #4
0
def parentheses(args: Element) -> Element:
    return ComplexElement('parentheses') \
        .add(PrimitiveElement('parenthesis_start', '(')) \
        .add(args) \
        .add(PrimitiveElement('parenthesis_end', ')'))
Beispiel #5
0
 def test_complex_element_should_print_nothing_when_empty(self):
     self.assertEqual('', str(ComplexElement()))
Beispiel #6
0
 def p_line_ending(p):
     """line_ending : line_comment newlines
                    | newlines"""
     p[0] = ComplexElement('line_ending')
     for element in p[1:]:
         p[0].add(element)
Beispiel #7
0
 def p_bracket_argument(p):
     """bracket_argument : BRACKET_ARGUMENT_START bracket_argument_content BRACKET_ARGUMENT_END"""
     p[0] = ComplexElement('bracket_argument') \
         .add(PrimitiveElement('bracket_start', p[1])) \
         .add(PrimitiveElement('bracket_argument_content', p[2].values)) \
         .add(PrimitiveElement('bracket_end', p[3]))
Beispiel #8
0
 def p_parentheses(p):
     """parentheses : start_parenthesis arguments end_parenthesis"""
     p[0] = ComplexElement('parentheses')
     for element in p[1:]:
         p[0].add(element)
Beispiel #9
0
 def p_command_invocation(p):
     """command_invocation : start_cmd_invoke arguments end_cmd_invoke"""
     p[0] = ComplexElement('command_invocation')
     for element in p[1:]:
         p[0].add(element)