Push an input source onto the lexer's input source stack.
(self, newstream, newfile=None)
| 74 | self.pushback.appendleft(tok) |
| 75 | |
| 76 | def push_source(self, newstream, newfile=None): |
| 77 | "Push an input source onto the lexer's input source stack." |
| 78 | if isinstance(newstream, str): |
| 79 | newstream = StringIO(newstream) |
| 80 | self.filestack.appendleft((self.infile, self.instream, self.lineno)) |
| 81 | self.infile = newfile |
| 82 | self.instream = newstream |
| 83 | self.lineno = 1 |
| 84 | if self.debug: |
| 85 | if newfile is not None: |
| 86 | print('shlex: pushing to file %s' % (self.infile,)) |
| 87 | else: |
| 88 | print('shlex: pushing to stream %s' % (self.instream,)) |
| 89 | |
| 90 | def pop_source(self): |
| 91 | "Pop the input source stack." |