[cfe-commits] r77777 - /cfe/trunk/utils/test/ShUtil.py
Daniel Dunbar
daniel at zuster.org
Fri Jul 31 22:52:05 PDT 2009
Author: ddunbar
Date: Sat Aug 1 00:52:04 2009
New Revision: 77777
URL: http://llvm.org/viewvc/llvm-project?rev=77777&view=rev
Log:
lit: Fix two sh lexing bugs.
- '\\\\' inside a "..." string becomes '\\'.
- The '<' token wasn't being recognized.
Modified:
cfe/trunk/utils/test/ShUtil.py
Modified: cfe/trunk/utils/test/ShUtil.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/test/ShUtil.py?rev=77777&r1=77776&r2=77777&view=diff
==============================================================================
--- cfe/trunk/utils/test/ShUtil.py (original)
+++ cfe/trunk/utils/test/ShUtil.py Sat Aug 1 00:52:04 2009
@@ -2,6 +2,9 @@
import Util
+# FIXME: It would be nice to at least match a few other things like `...`, $(
+# ... ), $VAR, etc., if only so we can nicely say "we don't support this".
+
class ShLexer:
def __init__(self, data):
self.data = data
@@ -82,9 +85,12 @@
self.data)
return str
c = self.eat()
- if c != delim:
+ if c == '"': #
+ str += '"'
+ elif c == '\\':
str += '\\'
- str += c
+ else:
+ str += '\\' + c
else:
str += c
Util.warning("missing quote character in %r" % self.data)
@@ -135,6 +141,7 @@
return ('<&',)
if self.maybe_eat('>'):
return ('<<',)
+ return (c,)
return self.lex_arg(c)
@@ -282,8 +289,9 @@
return list(ShLexer(str).lex())
def test_basic(self):
- self.assertEqual(self.lex('a|b>c&d'),
- ['a', ('|',), 'b', ('>',), 'c', ('&',), 'd'])
+ self.assertEqual(self.lex('a|b>c&d<e'),
+ ['a', ('|',), 'b', ('>',), 'c', ('&',), 'd',
+ ('<',), 'e'])
def test_redirection_tokens(self):
self.assertEqual(self.lex('a2>c'),
@@ -298,6 +306,8 @@
['hello"world'])
self.assertEqual(self.lex(""" "hello\\'world" """),
["hello\\'world"])
+ self.assertEqual(self.lex(""" "hello\\\\world" """),
+ ["hello\\world"])
self.assertEqual(self.lex(""" he"llo wo"rld """),
["hello world"])
More information about the cfe-commits
mailing list