diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-03 21:42:01 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-03 21:42:01 +0800 |
commit | 3e511bbd5af436e1c757ee68f8af409c0e66ed43 (patch) | |
tree | 2518aae4cb01ed537f7b28bd6d9a9cd07f3041fb /src/parse | |
parent | 8a374ca0ccf1eb01863323a9cb83de5c53c1e17d (diff) | |
download | mrust-3e511bbd5af436e1c757ee68f8af409c0e66ed43.tar.gz |
Parse - Fix incorrect pub(in)
Diffstat (limited to 'src/parse')
-rw-r--r-- | src/parse/root.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/parse/root.cpp b/src/parse/root.cpp index eb009622..406217f2 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -52,8 +52,22 @@ bool Parse_Publicity(TokenStream& lex, bool allow_restricted=true) if( LOOK_AHEAD(lex) == TOK_RWORD_PUB ) { GET_TOK(tok, lex); - if( allow_restricted && LOOK_AHEAD(lex) == TOK_PAREN_OPEN ) + if( LOOK_AHEAD(lex) == TOK_PAREN_OPEN ) { + // HACK: tuple structs have a parsing ambiguity around `pub (self::Type,)` + if( !allow_restricted ) + { + if( lex.lookahead(1) == TOK_RWORD_IN ) + ; + else if( lex.lookahead(1) == TOK_RWORD_CRATE && lex.lookahead(2) == TOK_PAREN_CLOSE ) + ; + else if( lex.lookahead(1) == TOK_RWORD_SUPER && lex.lookahead(2) == TOK_PAREN_CLOSE ) + ; + else if( lex.lookahead(1) == TOK_RWORD_SELF && lex.lookahead(2) == TOK_PAREN_CLOSE ) + ; + else + return true; + } auto path = AST::Path("", {}); // Restricted publicity. GET_TOK(tok, lex); // '(' @@ -80,7 +94,8 @@ bool Parse_Publicity(TokenStream& lex, bool allow_restricted=true) break; GET_TOK(tok, lex); GET_CHECK_TOK(tok, lex, TOK_IDENT); - case TOK_IDENT: + case TOK_RWORD_IN: + GET_CHECK_TOK(tok, lex, TOK_IDENT); path.nodes().push_back( AST::PathNode(tok.str()) ); while( LOOK_AHEAD(lex) == TOK_DOUBLE_COLON ) { |