47 std::string::const_iterator it = aString.begin();
55 std::string::const_iterator it = str.begin();
65 wxString fname(
From_UTF8( aFileName.c_str() ) );
66 wxFFile file( fname,
"rb" );
67 size_t length = file.Length();
71 throw PARSE_EXCEPTION(
"Error occurred attempting to read in file or empty file" );
76 file.Read( &str[0], str.length() );
82 std::string::const_iterator& it )
84 for( ; it != aString.end(); ++it )
94 std::advance( it, 1 );
96 auto list = std::make_unique<SEXPR_LIST>(
m_lineNumber );
98 while( it != aString.end() && *it !=
')' )
106 std::advance( it, 1 );
110 std::unique_ptr<SEXPR> item =
parseString( aString, it );
111 list->AddChild( item.release() );
114 if( it != aString.end() )
115 std::advance( it, 1 );
119 else if( *it ==
')' )
123 else if( *it ==
'"' )
127 auto starting_it = it;
129 for( ; it != aString.end(); ++it )
136 if( ++it == aString.end() )
146 if( it == aString.end() )
149 auto str = std::make_unique<SEXPR_STRING>( std::string( starting_it, it ),
158 size_t startPos = std::distance( aString.begin(), it );
161 std::string tmp = aString.substr( startPos, closingPos - startPos );
164 if( closingPos != std::string::npos )
166 if( tmp.find_first_not_of(
"0123456789." ) == std::string::npos ||
167 ( tmp.size() > 1 && tmp[0] ==
'-'
168 && tmp.find_first_not_of(
"0123456789.", 1 ) == std::string::npos ) )
170 std::unique_ptr<SEXPR>
res;
172 if( tmp.find(
'.' ) != std::string::npos )
174 res = std::make_unique<SEXPR_DOUBLE>(
180 res = std::make_unique<SEXPR_INTEGER>(
184 std::advance( it, closingPos - startPos );
189 auto str = std::make_unique<SEXPR_SYMBOL>( tmp,
m_lineNumber );
190 std::advance( it, closingPos - startPos );
static const std::string whitespaceCharacters
std::unique_ptr< SEXPR > parseString(const std::string &aString, std::string::const_iterator &it)
static std::string GetFileContents(const std::string &aFilename)
std::unique_ptr< SEXPR > ParseFromFile(const std::string &aFilename)
std::unique_ptr< SEXPR > Parse(const std::string &aString)
wxString From_UTF8(const char *cstring)