/* This extended command has to be in the outermost production so that
* the RPAREN_TOK is properly eaten and we are in a good state to read
* the included file's tokens. */
- | LPAREN_TOK INCLUDE_TOK str[name] RPAREN_TOK
+ | LPAREN_TOK INCLUDE_TOK str[name,true] RPAREN_TOK
{ if(!PARSER_STATE->canIncludeFile()) {
PARSER_STATE->parseError("include-file feature was disabled for this run.");
}
{ sexpr = SExpr(Integer(AntlrInput::tokenText($INTEGER_LITERAL))); }
| DECIMAL_LITERAL
{ sexpr = SExpr(AntlrInput::tokenToRational($DECIMAL_LITERAL)); }
- | str[s]
+ | str[s,false]
{ sexpr = SExpr(s); }
// | LPAREN_TOK STRCST_TOK
// ( INTEGER_LITERAL {
std::string binString = AntlrInput::tokenTextSubstr($BINARY_LITERAL, 2);
expr = MK_CONST( BitVector(binString, 2) ); }
- | str[s]
+ | str[s,false]
{ expr = MK_CONST( ::CVC4::String(s) ); }
// NOTE: Theory constants go here
/**
* Matches a string, and strips off the quotes.
*/
-str[std::string& s]
+str[std::string& s, bool fsmtlib]
: STRING_LITERAL
{ s = AntlrInput::tokenText($STRING_LITERAL);
/* strip off the quotes */
s = s.substr(1, s.size() - 2);
- /* handle SMT-LIB standard escapes '\\' and '\"' */
- char* p_orig = strdup(s.c_str());
- char *p = p_orig, *q = p_orig;
- while(*q != '\0') {
- if(*q == '\\') {
- ++q;
- if(*q == '\\' || *q == '"') {
- *p++ = *q++;
- } else {
- assert(*q != '\0');
- *p++ = '\\';
- *p++ = *q++;
- }
- } else {
- *p++ = *q++;
- }
- }
- *p = '\0';
- s = p_orig;
- free(p_orig);
+ if(fsmtlib) {
+ /* handle SMT-LIB standard escapes '\\' and '\"' */
+ char* p_orig = strdup(s.c_str());
+ char *p = p_orig, *q = p_orig;
+ while(*q != '\0') {
+ if(*q == '\\') {
+ ++q;
+ if(*q == '\\' || *q == '"') {
+ *p++ = *q++;
+ } else {
+ assert(*q != '\0');
+ *p++ = '\\';
+ *p++ = *q++;
+ }
+ } else {
+ *p++ = *q++;
+ }
+ }
+ *p = '\0';
+ s = p_orig;
+ free(p_orig);
+ }
}
;
}
}
} else {
- //throw CVC4::Exception( "Error String Literal: \"" + s + "\"" );
- d_str.push_back( convertCharToUnsignedInt('\\') );
+ throw CVC4::Exception( "should be handled by lexer: \"" + s + "\"" );
+ //d_str.push_back( convertCharToUnsignedInt('\\') );
}
} else {
d_str.push_back( convertCharToUnsignedInt(s[i]) );
char c = convertUnsignedIntToChar( d_str[i] );
if(isprint( c )) {
if(c == '\\') {
- str += "\\";
+ str += "\\\\";
} else if(c == '\"') {
str += "\\\"";
} else {
case '\e': s = "\\e"; break;
default : {
std::string s2 = static_cast<std::ostringstream*>( &(std::ostringstream() << (int)c) )->str();
+ if(s2.size() == 1) {
+ s2 = "0" + s2;
+ }
s = "\\x" + s2;
}
}