diff options
author | John Hodge <tpg@mutabah.net> | 2016-01-30 13:40:50 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-01-30 13:40:50 +0800 |
commit | bc4c6189980d2fc1c8e753b9cd614699652ecba7 (patch) | |
tree | 60da422be5349dbf3ad5bf2eeaea487e481861ac | |
parent | 48eec4328930a9bd6084f95fd79257068d738c91 (diff) | |
download | mrust-bc4c6189980d2fc1c8e753b9cd614699652ecba7.tar.gz |
Syntax updates and new language items
-rw-r--r-- | src/parse/expr.cpp | 6 | ||||
-rw-r--r-- | src/parse/pattern.cpp | 2 | ||||
-rw-r--r-- | src/parse/root.cpp | 19 | ||||
-rw-r--r-- | src/synexts/lang_item.cpp | 11 |
4 files changed, 34 insertions, 4 deletions
diff --git a/src/parse/expr.cpp b/src/parse/expr.cpp index 285531eb..5c7bfda5 100644 --- a/src/parse/expr.cpp +++ b/src/parse/expr.cpp @@ -548,6 +548,8 @@ ExprNodeP Parse_Stmt(TokenStream& lex) TRACE_FUNCTION;
Token tok;
+ CLEAR_PARSE_FLAG(lex, disallow_struct_literal);
+
::std::vector<ExprNodeP> rv;
GET_CHECK_TOK(tok, lex, TOK_PAREN_OPEN);
if( GET_TOK(tok, lex) != TOK_PAREN_CLOSE )
@@ -579,6 +581,8 @@ ExprNodeP Parse_Expr0(TokenStream& lex) op = AST::ExprNode_Assign::MUL; if(0)
case TOK_SLASH_EQUAL:
op = AST::ExprNode_Assign::DIV; if(0)
+ case TOK_PERCENT_EQUAL:
+ op = AST::ExprNode_Assign::MOD; if(0)
case TOK_AMP_EQUAL:
op = AST::ExprNode_Assign::AND; if(0)
@@ -918,7 +922,7 @@ ExprNodeP Parse_ExprVal_Closure(TokenStream& lex, bool is_move) CHECK_TOK(tok, TOK_PIPE);
TypeRef rt;
- if( GET_TOK(tok, lex) == TOK_COLON )
+ if( GET_TOK(tok, lex) == TOK_THINARROW )
rt = Parse_Type(lex);
else
lex.putback(tok);
diff --git a/src/parse/pattern.cpp b/src/parse/pattern.cpp index 1da59951..02286ceb 100644 --- a/src/parse/pattern.cpp +++ b/src/parse/pattern.cpp @@ -153,6 +153,8 @@ AST::Pattern Parse_PatternReal1(TokenStream& lex, bool is_refutable) return AST::Pattern( ); case TOK_DOUBLE_DOT: return AST::Pattern( AST::Pattern::TagWildcard() ); + case TOK_DOUBLE_AMP: + lex.putback(TOK_AMP); case TOK_AMP: DEBUG("Ref"); // NOTE: Falls back into "Pattern" not "PatternReal" to handle MaybeBind again diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 462922d2..d2fc80b1 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -88,7 +88,10 @@ AST::TypeParams Parse_TypeParams(TokenStream& lex) Token tok;
do {
bool is_lifetime = false;
- switch( GET_TOK(tok, lex) )
+ if( GET_TOK(tok, lex) == TOK_GT ) {
+ break ;
+ }
+ switch( tok.type() )
{
case TOK_IDENT:
break;
@@ -853,9 +856,15 @@ void Parse_Impl_Item(TokenStream& lex, AST::Impl& impl) GET_CHECK_TOK(tok, lex, TOK_SEMICOLON);
break; }
case TOK_RWORD_CONST:
- if( GET_TOK(tok, lex) != TOK_RWORD_FN )
+ if( GET_TOK(tok, lex) != TOK_RWORD_FN && tok.type() != TOK_RWORD_UNSAFE )
{
- throw ParseError::Todo("Associated const");
+ BUG(lex.end_span(lex.start_span()), "TODO: Associated const");
+ }
+ else if( tok.type() == TOK_RWORD_UNSAFE )
+ {
+ if( GET_TOK(tok, lex) != TOK_RWORD_FN )
+ ERROR(lex.end_span(lex.start_span()), E0000, "");
+ item_attrs.push_back( AST::MetaItem("#UNSAFE") );
}
if( 0 )
case TOK_RWORD_EXTERN:
@@ -1697,6 +1706,10 @@ AST::Crate Parse_Crate(::std::string mainfile) {
if( attr.name() == "no_std" ) {
crate.m_load_std = false;
+ // TODO: Load core instead
+ }
+ else if( attr.name() == "no_core" ) {
+ crate.m_load_std = false;
}
else {
// TODO:
diff --git a/src/synexts/lang_item.cpp b/src/synexts/lang_item.cpp index 9e3f0aa9..fb831539 100644 --- a/src/synexts/lang_item.cpp +++ b/src/synexts/lang_item.cpp @@ -44,6 +44,17 @@ void handle_lang_item(AST::Crate& crate, const AST::Path& path, const ::std::str else if( name == "bitxor" ) { DEBUG("Bind '"<<name<<"' to " << path); } else if( name == "shl" ) { DEBUG("Bind '"<<name<<"' to " << path); } else if( name == "shr" ) { DEBUG("Bind '"<<name<<"' to " << path); } + + else if( name == "add_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "sub_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "div_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "rem_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "mul_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "bitand_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "bitor_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "bitxor_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "shl_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "shr_assign" ) { DEBUG("Bind '"<<name<<"' to " << path); } else if( name == "index" ) { DEBUG("Bind '"<<name<<"' to " << path); } else if( name == "deref" ) { DEBUG("Bind '"<<name<<"' to " << path); } |