diff options
| author | John Hodge (bugs) <tpg@mutabah.net> | 2017-03-04 18:12:49 +0800 |
|---|---|---|
| committer | John Hodge (bugs) <tpg@mutabah.net> | 2017-03-04 18:12:49 +0800 |
| commit | c6fca061dd134068c831aefd88d9535a30f423ed (patch) | |
| tree | 28fc4abecddf8514792a4cb748f1c6e5700274c1 /src/parse | |
| parent | 03addc877bab648ccde022edec29f5b051ce7cb9 (diff) | |
| download | mrust-c6fca061dd134068c831aefd88d9535a30f423ed.tar.gz | |
Many many changes to allow compiling in visual studio (Community 2015)
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/expr.cpp | 2 | ||||
| -rw-r--r-- | src/parse/lex.cpp | 13 | ||||
| -rw-r--r-- | src/parse/pattern.cpp | 2 | ||||
| -rw-r--r-- | src/parse/token.cpp | 5 | ||||
| -rw-r--r-- | src/parse/token.hpp | 2 | ||||
| -rw-r--r-- | src/parse/tokenstream.cpp | 5 |
6 files changed, 15 insertions, 14 deletions
diff --git a/src/parse/expr.cpp b/src/parse/expr.cpp index d4edb208..6227dca4 100644 --- a/src/parse/expr.cpp +++ b/src/parse/expr.cpp @@ -950,7 +950,7 @@ ExprNodeP Parse_ExprVal_StructLiteral(TokenStream& lex, AST::Path path) ::std::map<unsigned int, ExprNodeP> nodes; while( GET_TOK(tok, lex) == TOK_INTEGER ) { - unsigned int ofs = tok.intval(); + unsigned int ofs = static_cast<unsigned int>(tok.intval()); GET_CHECK_TOK(tok, lex, TOK_COLON); ExprNodeP val = Parse_Stmt(lex); if( ! nodes.insert( ::std::make_pair(ofs, mv$(val)) ).second ) { diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp index 4e5b4c2d..caa640f9 100644 --- a/src/parse/lex.cpp +++ b/src/parse/lex.cpp @@ -14,6 +14,7 @@ #include <cstdlib> // strtol #include <typeinfo> #include <algorithm> // std::count +#include <cctype> Lexer::Lexer(const ::std::string& filename): m_path(filename.c_str()), @@ -222,7 +223,9 @@ signed int Lexer::getSymbol() bool issym(Codepoint ch) { - if( ::std::isalnum(ch.v) ) + if('0' <= ch.v && ch.v <= '9') + return true; + if( ::std::isalpha(ch.v) ) return true; if( ch == '_' ) return true; @@ -659,11 +662,11 @@ Token Lexer::getTokenInt() } } } - catch(const Lexer::EndOfFile& e) + catch(const Lexer::EndOfFile& /*e*/) { return Token(TOK_EOF); } - //assert(!"bugcheck"); + throw "Fell off the end of getTokenInt"; } Token Lexer::getTokenInt_RawString(bool is_byte) @@ -693,7 +696,7 @@ Token Lexer::getTokenInt_RawString(bool is_byte) try { ch = this->getc(); } - catch( Lexer::EndOfFile e ) { + catch( const Lexer::EndOfFile& /*e*/ ) { throw ParseError::Generic(*this, "EOF reached in raw string"); } @@ -981,7 +984,7 @@ bool Codepoint::isspace() const { case ' ': case 0xC: // ^L case 0x85: - case 0x200E ... 0x200F: // LTR / RTL markers + case 0x200E: case 0x200F: // LTR / RTL markers case 0x2028: // Line Separator case 0x2029: // Paragrah Separator return true; diff --git a/src/parse/pattern.cpp b/src/parse/pattern.cpp index 699e7fae..72b3eac4 100644 --- a/src/parse/pattern.cpp +++ b/src/parse/pattern.cpp @@ -409,7 +409,7 @@ AST::Pattern Parse_PatternStruct(TokenStream& lex, AST::Path path, bool is_refut ::std::map<unsigned int, AST::Pattern> pats; while( GET_TOK(tok, lex) == TOK_INTEGER ) { - unsigned int ofs = tok.intval(); + unsigned int ofs = static_cast<unsigned int>(tok.intval()); GET_CHECK_TOK(tok, lex, TOK_COLON); auto val = Parse_Pattern(lex, is_refutable); if( ! pats.insert( ::std::make_pair(ofs, mv$(val)) ).second ) { diff --git a/src/parse/token.cpp b/src/parse/token.cpp index 69b952cc..c7d11d03 100644 --- a/src/parse/token.cpp +++ b/src/parse/token.cpp @@ -244,11 +244,10 @@ enum eTokenType Token::typefromstr(const ::std::string& s) { if(s == "") return TOK_NULL; - #define _(t) else if( s == #t ) return t; + #define _(t) if( s == #t ) return t; #include "eTokenType.enum.h" #undef _ - else - return TOK_NULL; + return TOK_NULL; } struct EscapedString { diff --git a/src/parse/token.hpp b/src/parse/token.hpp index 03117981..0ef8f009 100644 --- a/src/parse/token.hpp +++ b/src/parse/token.hpp @@ -108,7 +108,7 @@ public: enum eTokenType type() const { return m_type; } ::std::string& str() { return m_data.as_String(); } const ::std::string& str() const { return m_data.as_String(); } - enum eCoreType datatype() const { TU_MATCH_DEF(Data, (m_data), (e), (assert(!"Getting datatype of invalid token type");), (Integer, return e.m_datatype;), (Float, return e.m_datatype;)) } + enum eCoreType datatype() const { TU_MATCH_DEF(Data, (m_data), (e), (assert(!"Getting datatype of invalid token type");), (Integer, return e.m_datatype;), (Float, return e.m_datatype;)) throw ""; } uint64_t intval() const { return m_data.as_Integer().m_intval; } double floatval() const { return m_data.as_Float().m_floatval; } diff --git a/src/parse/tokenstream.cpp b/src/parse/tokenstream.cpp index 9a961a04..491b2a3e 100644 --- a/src/parse/tokenstream.cpp +++ b/src/parse/tokenstream.cpp @@ -105,9 +105,8 @@ ProtoSpan TokenStream::start_span() const { auto p = this->getPosition(); return ProtoSpan { - .filename = p.filename, - .start_line = p.line, - .start_ofs = p.ofs, + p.filename, + p.line, p.ofs }; } Span TokenStream::end_span(ProtoSpan ps) const |
