summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/expr.cpp2
-rw-r--r--src/parse/interpolated_fragment.hpp2
-rw-r--r--src/parse/lex.cpp13
-rw-r--r--src/parse/pattern.cpp2
-rw-r--r--src/parse/token.cpp5
-rw-r--r--src/parse/token.hpp5
-rw-r--r--src/parse/tokenstream.cpp7
7 files changed, 19 insertions, 17 deletions
diff --git a/src/parse/expr.cpp b/src/parse/expr.cpp
index ab863600..28729b93 100644
--- a/src/parse/expr.cpp
+++ b/src/parse/expr.cpp
@@ -965,7 +965,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/interpolated_fragment.hpp b/src/parse/interpolated_fragment.hpp
index a3e72816..1b18845a 100644
--- a/src/parse/interpolated_fragment.hpp
+++ b/src/parse/interpolated_fragment.hpp
@@ -11,7 +11,7 @@ namespace AST {
class Path;
class ExprNode;
class MetaItem;
- template<typename T> class Named;
+ template<typename T> struct Named;
class Item;
};
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index 71ccbfb2..0587e443 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;
@@ -661,11 +664,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)
@@ -695,7 +698,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");
}
@@ -980,7 +983,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 aed2c91d..e9d086f9 100644
--- a/src/parse/pattern.cpp
+++ b/src/parse/pattern.cpp
@@ -410,7 +410,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 cf0038bd..ffa566f4 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 0fcf0ed7..0ef8f009 100644
--- a/src/parse/token.hpp
+++ b/src/parse/token.hpp
@@ -49,8 +49,9 @@ namespace AST {
class ExprNode;
class MetaItem;
class Item;
+
template<typename T>
- class Named;
+ struct Named;
};
class InterpolatedFragment;
@@ -107,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 5322822f..8cb9a910 100644
--- a/src/parse/tokenstream.cpp
+++ b/src/parse/tokenstream.cpp
@@ -24,7 +24,7 @@ TokenStream::~TokenStream()
Token TokenStream::innerGetToken()
{
Token ret = this->realGetToken();
- if( ret.get_pos().filename == "" )
+ if( ret != TOK_EOF && ret.get_pos().filename == "" )
ret.set_pos( this->getPosition() );
//DEBUG("ret.get_pos() = " << ret.get_pos());
return ret;
@@ -109,9 +109,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