Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / lib / python2.4 / shlex.py
CommitLineData
86530b38
AT
1# -*- coding: iso-8859-1 -*-
2"""A lexical analyzer class for simple shell-like syntaxes."""
3
4# Module and documentation by Eric S. Raymond, 21 Dec 1998
5# Input stacking and error message cleanup added by ESR, March 2000
6# push_source() and pop_source() made explicit by ESR, January 2001.
7# Posix compliance, split(), string arguments, and
8# iterator interface by Gustavo Niemeyer, April 2003.
9
10import os.path
11import sys
12from collections import deque
13
14try:
15 from cStringIO import StringIO
16except ImportError:
17 from StringIO import StringIO
18
19__all__ = ["shlex", "split"]
20
21class shlex:
22 "A lexical analyzer class for simple shell-like syntaxes."
23 def __init__(self, instream=None, infile=None, posix=False):
24 if isinstance(instream, basestring):
25 instream = StringIO(instream)
26 if instream is not None:
27 self.instream = instream
28 self.infile = infile
29 else:
30 self.instream = sys.stdin
31 self.infile = None
32 self.posix = posix
33 if posix:
34 self.eof = None
35 else:
36 self.eof = ''
37 self.commenters = '#'
38 self.wordchars = ('abcdfeghijklmnopqrstuvwxyz'
39 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_')
40 if self.posix:
41