def t_doublequote(self, s, m, parent): r'" [^"\\\n]* ( ( ((\\(.|\n)|\n)[\s?]*) | "" ) [^"\\\n]* )* "' if parent.current[-1] == _COMMAND_MODE: parent.addToken(type=parent.argsep) parent.argsep = ',' nline = _countNewlines(s) # Recognize and remove any embedded comments s = comment_pat.sub('', s) s = filterEscapes( irafutils.removeEscapes(irafutils.stripQuotes(s), quoted=1)) parent.addToken(type='QSTRING', attr=s) parent.lineno = parent.lineno + nline
def t_string(self, s, m, parent): r'[^ \t\n()\\;{}&]+(\\(.|\n)[^ \t\n()\\;{}&]*)*' # What other characters are forbidden in unquoted strings? # Allowing escaped newlines, blanks, quotes, etc. # Increment line count for embedded newlines (after adding token) parent.addToken(type=parent.argsep) parent.argsep = ',' nline = _countNewlines(s) # Handle special escapes then, escape all remaining backslashes # since IRAF doesn't deal with special characters in this mode. # Thus PyRAF should leave them as literal backslashes within its # strings. Why IRAF does this I have no idea. s = irafutils.removeEscapes(s).replace('\\', '\\\\') parent.addToken(type='STRING', attr=s) parent.lineno = parent.lineno + nline
def t_singlequote(self, s, m, parent): r"' [^'\\\n]* ( ( ((\\(.|\n)|\n)[\s?]*) | '' ) [^'\\\n]* )*'" # this pattern allows both escaped embedded quotes and # embedded double quotes ('embedded''quotes') # it also allows escaped newlines if parent.current[-1] == _COMMAND_MODE: parent.addToken(type=parent.argsep) parent.argsep = ',' nline = _countNewlines(s) # Recognize and remove any embedded comments s = comment_pat.sub('', s) s = filterEscapes( irafutils.removeEscapes(irafutils.stripQuotes(s), quoted=1)) # We use a different type for quoted strings to protect them # against conversion to other token types by enterComputeEqnMode parent.addToken(type='QSTRING', attr=s) parent.lineno = parent.lineno + nline