1# ScummVM - Graphic Adventure Engine 2# 3# ScummVM is the legal property of its developers, whose names 4# are too numerous to list here. Please refer to the COPYRIGHT 5# file distributed with this source distribution. 6# 7# This program is free software; you can redistribute it and/or 8# modify it under the terms of the GNU General Public License 9# as published by the Free Software Foundation; either version 2 10# of the License, or (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program; if not, write to the Free Software 19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20# 21 22def parse_args(text): 23 #print "parsing: [%s]" %text 24 escape = False 25 string = False 26 result = [] 27 token = str() 28 value = 0; 29 for c in text: 30 #print "[%s]%s: %s: %s" %(token, c, escape, string) 31 if c == '\\': 32 escape = True 33 continue 34 35 if escape: 36 if not string: 37 raise SyntaxError("escape found in no string: %s" %text); 38 39 #print "escaping[%s]" %c 40 escape = False 41 token += c 42 continue 43 44 if string: 45 if c == '\'' or c == '"': 46 string = False 47 48 token += c 49 continue 50 51 if c == '\'' or c == '"': 52 string = True 53 token += c 54 continue 55 56 if c == ',': 57 result.append(token.strip()) 58 token = str() 59 continue 60 61 if c == ';': #comment, bailing out 62 break 63 64 token += c 65 #token = token.strip() 66 if len(token): 67 result.append(token) 68 #print result 69 return result 70 71def compile(width, data): 72 print data 73 return data 74