Example #1
0
 def _codegen_impl(self, state: CodegenState) -> None:
     self.whitespace_before._codegen(state)
     with state.record_syntactic_position(self):
         state.add_token(self._get_tokens()[0])
         self.whitespace_between._codegen(state)
         state.add_token(self._get_tokens()[1])
     self.whitespace_after._codegen(state)
Example #2
0
    def _codegen_impl(self, state: CodegenState) -> None:
        with state.record_syntactic_position(self):
            self.target._codegen(state)

        self.whitespace_before_equal._codegen(state)
        # U+21D0 is "Leftwards Double Arrow" (a nice unicode rendering of
        # SystemVerilog's "<=" which doesn't collide with less-than-or-equal.
        state.add_token("\u21d0")
        self.whitespace_after_equal._codegen(state)
Example #3
0
 def _codegen_impl(self, state: CodegenState) -> None:
     for h in self.header:
         h._codegen(state)
     for stmt in self.body:
         stmt._codegen(state)
     for f in self.footer:
         f._codegen(state)
     if self.has_trailing_newline:
         if len(state.tokens) == 0:
             # There was nothing in the header, footer, or body. Just add a newline
             # to preserve the trailing newline.
             state.add_token(state.default_newline)
     else:  # has_trailing_newline is false
         state.pop_trailing_newline()
Example #4
0
 def _codegen_impl(self, state: CodegenState) -> None:
     for h in self.header:
         h._codegen(state)
     for stmt in self.body:
         stmt._codegen(state)
     for f in self.footer:
         f._codegen(state)
     if self.has_trailing_newline:
         if len(state.tokens) == 0:
             # There was nothing in the header, footer, or body. Just add a newline
             # to preserve the trailing newline.
             state.add_token(state.default_newline)
     else:  # has_trailing_newline is false
         if len(state.tokens) > 0:
             # EmptyLine and all statements generate newlines, so we can be sure that
             # the last token (if we're not an empty file) is a newline.
             state.tokens.pop()
Example #5
0
 def _codegen_impl(self, state: CodegenState) -> None:
     state.add_token(self.value)
Example #6
0
 def _codegen_impl(self, state: CodegenState) -> None:
     value = self.value
     state.add_token(state.default_newline if value is None else value)
Example #7
0
 def _codegen_impl(self, state: CodegenState) -> None:
     self.whitespace_before._codegen(state)
     state.add_token(self.value)
     self.whitespace_after._codegen(state)
Example #8
0
 def _codegen_impl(self, state: CodegenState) -> None:
     state.add_token(self._get_token())
     self.whitespace_after._codegen(state)