Esempio n. 1
0
def newlines(number: int) -> Element:
    return ComplexElement('line_ending').add(
        PrimitiveElement('newlines', number))
Esempio n. 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}]'))
Esempio n. 3
0
def line_ending(comment, newlines_number):
    return ComplexElement('line_ending') \
        .add(PrimitiveElement('line_comment', comment)) \
        .add(PrimitiveElement('newlines', newlines_number))
Esempio n. 4
0
def parentheses(args: Element) -> Element:
    return ComplexElement('parentheses') \
        .add(PrimitiveElement('parenthesis_start', '(')) \
        .add(args) \
        .add(PrimitiveElement('parenthesis_end', ')'))
Esempio n. 5
0
 def test_complex_element_should_print_nothing_when_empty(self):
     self.assertEqual('', str(ComplexElement()))
Esempio n. 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)
Esempio n. 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]))
Esempio n. 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)
Esempio n. 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)