diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-10 14:33:01 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-10 14:33:01 +0800 |
commit | 51a04ad6e7b451eb3543fe97a1dfe9430f3a4436 (patch) | |
tree | 7ef3642343b927bb7045f9142468beb30771656b /src/parse | |
parent | 32ed843e8ebafc22f61c3f166bcb4af0ce7f4fd7 (diff) | |
download | mrust-51a04ad6e7b451eb3543fe97a1dfe9430f3a4436.tar.gz |
Parse - Remove old inefficient TT parse code
Diffstat (limited to 'src/parse')
-rw-r--r-- | src/parse/expr.cpp | 117 | ||||
-rw-r--r-- | src/parse/tokentree.hpp | 7 |
2 files changed, 0 insertions, 124 deletions
diff --git a/src/parse/expr.cpp b/src/parse/expr.cpp index 6b33b3e7..5463f50f 100644 --- a/src/parse/expr.cpp +++ b/src/parse/expr.cpp @@ -1295,120 +1295,3 @@ TokenTree Parse_TT(TokenStream& lex, bool unwrapped) items.push_back( mv$(tok) );
return TokenTree(mv$(items));
}
-
-/// A wrapping lexer that
-class TTLexer:
- public TokenStream
-{
- TokenStream& m_input;
- Token m_last_token;
- ::std::vector<TokenTree> m_output;
-public:
- TTLexer(TokenStream& input):
- m_input(input)
- {
- }
-
- virtual Position getPosition() const override { return m_input.getPosition(); }
- virtual Token realGetToken() override {
- Token tok = m_input.getToken();
- m_output.push_back( TokenTree(tok.clone()) );
- return tok;
- }
-
- TokenTree get_output() {
- unsigned int eat = (TokenStream::m_cache_valid ? 1 : 0) + TokenStream::m_lookahead.size();
- DEBUG(eat << " tokens were not consumed");
- assert( m_output.size() >= eat );
- assert( m_input.m_lookahead.size() == 0 );
- assert( m_input.m_cache_valid == false );
- for( unsigned int i = 0; i < eat; i ++ )
- {
- Token tok = m_output[ m_output.size() - eat + i ].tok();
- DEBUG("Unconsume " << tok);
- m_input.m_lookahead.push_back( tok );
- }
- DEBUG("- output was [" << m_output << "]");
- m_output.erase( m_output.end() - eat, m_output.end() );
- DEBUG("Returning [" << m_output << "]");
- return ::std::move(m_output);
- }
-};
-
-TokenTree Parse_TT_Type(TokenStream& lex)
-{
- TRACE_FUNCTION;
- TTLexer wlex(lex);
- SET_PARSE_FLAG(wlex, no_expand_macros);
-
- // discard result
- Parse_Type(wlex);
-
- return wlex.get_output();
-}
-
-/// Parse a token tree path
-TokenTree Parse_TT_Path(TokenStream& lex, bool mode_expr)
-{
- TRACE_FUNCTION;
- TTLexer wlex(lex);
- SET_PARSE_FLAG(wlex, no_expand_macros);
-
- Token tok;
-
- if( GET_TOK(tok, wlex) == TOK_DOUBLE_COLON ) {
- Parse_Path(wlex, true, (mode_expr ? PATH_GENERIC_EXPR : PATH_GENERIC_TYPE));
- }
- else {
- PUTBACK(tok, lex);
- Parse_Path(wlex, false, (mode_expr ? PATH_GENERIC_EXPR : PATH_GENERIC_TYPE));
- }
-
- return wlex.get_output();
-}
-/// Parse a token tree expression
-TokenTree Parse_TT_Expr(TokenStream& lex)
-{
- TRACE_FUNCTION;
- TTLexer wlex(lex);
- SET_PARSE_FLAG(wlex, no_expand_macros);
-
- Parse_Expr1(wlex);
-
- return wlex.get_output();
-}
-TokenTree Parse_TT_Pattern(TokenStream& lex)
-{
- TRACE_FUNCTION;
- TTLexer wlex(lex);
- SET_PARSE_FLAG(wlex, no_expand_macros);
-
- // Allow a refutable pattern here
- Parse_Pattern(wlex, true);
-
- return wlex.get_output();
-}
-TokenTree Parse_TT_Stmt(TokenStream& lex)
-{
- TRACE_FUNCTION;
- TTLexer wlex(lex);
- SET_PARSE_FLAG(wlex, no_expand_macros);
-
- throw ParseError::Todo("Parse_TT_Stmt");
-}
-TokenTree Parse_TT_Block(TokenStream& lex)
-{
- TRACE_FUNCTION;
- TTLexer wlex(lex);
- SET_PARSE_FLAG(wlex, no_expand_macros);
-
- throw ParseError::Todo("Parse_TT_Block");
-}
-TokenTree Parse_TT_Meta(TokenStream& lex)
-{
- TRACE_FUNCTION;
- TTLexer wlex(lex);
- SET_PARSE_FLAG(wlex, no_expand_macros);
- Parse_MetaItem(wlex);
- return wlex.get_output();
-}
diff --git a/src/parse/tokentree.hpp b/src/parse/tokentree.hpp index 0856c326..82c4f97d 100644 --- a/src/parse/tokentree.hpp +++ b/src/parse/tokentree.hpp @@ -90,12 +90,5 @@ protected: // unwrapped = Exclude the enclosing brackets (used by macro parse code)
extern TokenTree Parse_TT(TokenStream& lex, bool unwrapped);
-extern TokenTree Parse_TT_Pattern(TokenStream& lex);
-extern TokenTree Parse_TT_Expr(TokenStream& lex);
-extern TokenTree Parse_TT_Type(TokenStream& lex);
-extern TokenTree Parse_TT_Stmt(TokenStream& lex);
-extern TokenTree Parse_TT_Block(TokenStream& lex);
-extern TokenTree Parse_TT_Path(TokenStream& lex, bool mode_expr);
-extern TokenTree Parse_TT_Meta(TokenStream& lex);
#endif // TOKENTREE_HPP_INCLUDED
|