_scons_shlex.py
上传用户:market2
上传日期:2018-11-18
资源大小:18786k
文件大小:11k
- # -*- coding: iso-8859-1 -*-
- """A lexical analyzer class for simple shell-like syntaxes."""
- # Module and documentation by Eric S. Raymond, 21 Dec 1998
- # Input stacking and error message cleanup added by ESR, March 2000
- # push_source() and pop_source() made explicit by ESR, January 2001.
- # Posix compliance, split(), string arguments, and
- # iterator interface by Gustavo Niemeyer, April 2003.
- import os.path
- import sys
- #from collections import deque
- class deque:
- def __init__(self):
- self.data = []
- def __len__(self):
- return len(self.data)
- def appendleft(self, item):
- self.data.insert(0, item)
- def popleft(self):
- return self.data.pop(0)
- try:
- basestring
- except NameError:
- import types
- def is_basestring(s):
- return type(s) is types.StringType
- else:
- def is_basestring(s):
- return isinstance(s, basestring)
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- __all__ = ["shlex", "split"]
- class shlex:
- "A lexical analyzer class for simple shell-like syntaxes."
- def __init__(self, instream=None, infile=None, posix=False):
- if is_basestring(instream):
- instream = StringIO(instream)
- if instream is not None:
- self.instream = instream
- self.infile = infile
- else:
- self.instream = sys.stdin
- self.infile = None
- self.posix = posix
- if posix:
- self.eof = None
- else:
- self.eof = ''
- self.commenters = '#'
- self.wordchars = ('abcdfeghijklmnopqrstuvwxyz'
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_')
- if self.posix:
- self.wordchars = self.wordchars + ('哙徕沅彐玷殛腱眍镳耱篝貊