chore(frontends/lean): remove script blocks

This commit is contained in:
Leonardo de Moura 2016-02-08 18:50:00 -08:00
parent f67181baf3
commit 9cbda49297
4 changed files with 3 additions and 17 deletions

View file

@ -1724,7 +1724,7 @@ unsigned parser::curr_lbp_core(bool as_tactic) const {
else else
return get_token_info().expr_precedence(); return get_token_info().expr_precedence();
case scanner::token_kind::CommandKeyword: case scanner::token_kind::Eof: case scanner::token_kind::CommandKeyword: case scanner::token_kind::Eof:
case scanner::token_kind::ScriptBlock: case scanner::token_kind::QuotedSymbol: case scanner::token_kind::QuotedSymbol:
return 0; return 0;
case scanner::token_kind::Backtick: case scanner::token_kind::Backtick:
return m_in_backtick ? 0 : get_max_prec(); return m_in_backtick ? 0 : get_max_prec();
@ -2225,8 +2225,6 @@ bool parser::curr_is_command_like() const {
switch (curr()) { switch (curr()) {
case scanner::token_kind::CommandKeyword: case scanner::token_kind::CommandKeyword:
return true; return true;
case scanner::token_kind::ScriptBlock:
return true;
case scanner::token_kind::Eof: case scanner::token_kind::Eof:
return true; return true;
case scanner::token_kind::Keyword: case scanner::token_kind::Keyword:

View file

@ -282,11 +282,6 @@ void scanner::read_until(char const * end_str, char const * error_msg) {
} }
} }
auto scanner::read_script_block() -> token_kind {
read_until("*)", "unexpected end of script");
return token_kind::ScriptBlock;
}
void scanner::move_back(unsigned offset, unsigned u_offset) { void scanner::move_back(unsigned offset, unsigned u_offset) {
lean_assert(m_uskip == 0); lean_assert(m_uskip == 0);
if (offset != 0) { if (offset != 0) {
@ -419,18 +414,15 @@ auto scanner::read_key_cmd_id() -> token_kind {
} }
} }
static name * g_begin_script_tk = nullptr;
static name * g_begin_comment_tk = nullptr; static name * g_begin_comment_tk = nullptr;
static name * g_begin_comment_block_tk = nullptr; static name * g_begin_comment_block_tk = nullptr;
void initialize_scanner() { void initialize_scanner() {
g_begin_script_tk = new name("(*");
g_begin_comment_tk = new name("--"); g_begin_comment_tk = new name("--");
g_begin_comment_block_tk = new name("/-"); g_begin_comment_block_tk = new name("/-");
} }
void finalize_scanner() { void finalize_scanner() {
delete g_begin_script_tk;
delete g_begin_comment_tk; delete g_begin_comment_tk;
delete g_begin_comment_block_tk; delete g_begin_comment_block_tk;
} }
@ -468,8 +460,6 @@ auto scanner::scan(environment const & env) -> token_kind {
read_single_line_comment(); read_single_line_comment();
else if (n == *g_begin_comment_block_tk) else if (n == *g_begin_comment_block_tk)
read_comment_block(); read_comment_block();
else if (n == *g_begin_script_tk)
return read_script_block();
else else
return k; return k;
} else { } else {

View file

@ -17,13 +17,13 @@ namespace lean {
/** /**
\brief Scanner. The behavior of the scanner is controlled using a token set. \brief Scanner. The behavior of the scanner is controlled using a token set.
The scanner has builtin support for comments, script blocks, The scanner has builtin support for comments,
identifiers, numerals, decimals, strings. Everything else is only identifiers, numerals, decimals, strings. Everything else is only
accepted if they are in the token set. accepted if they are in the token set.
*/ */
class scanner { class scanner {
public: public:
enum class token_kind {Keyword, CommandKeyword, ScriptBlock, Identifier, Numeral, Decimal, String, QuotedSymbol, Backtick, Eof}; enum class token_kind {Keyword, CommandKeyword, Identifier, Numeral, Decimal, String, QuotedSymbol, Backtick, Eof};
protected: protected:
token_table const * m_tokens; token_table const * m_tokens;
std::istream & m_stream; std::istream & m_stream;
@ -66,7 +66,6 @@ protected:
token_kind read_string(); token_kind read_string();
token_kind read_number(); token_kind read_number();
token_kind read_script_block();
token_kind read_key_cmd_id(); token_kind read_key_cmd_id();
token_kind read_quoted_symbol(); token_kind read_quoted_symbol();

View file

@ -158,7 +158,6 @@ static void tst2() {
check("{x}", {tk::Keyword, tk::Identifier, tk::Keyword}); check("{x}", {tk::Keyword, tk::Identifier, tk::Keyword});
check("\u03BB \u2200 \u2192", {tk::Keyword, tk::Keyword, tk::Keyword}); check("\u03BB \u2200 \u2192", {tk::Keyword, tk::Keyword, tk::Keyword});
check_keyword("\u03BB", "fun"); check_keyword("\u03BB", "fun");
scan("x10 ... (* print('hello') *) have by");
scan("0..1"); scan("0..1");
check("0..1", {tk::Numeral, tk::Keyword, tk::Keyword, tk::Numeral}); check("0..1", {tk::Numeral, tk::Keyword, tk::Keyword, tk::Numeral});
scan("theorem a : Prop axiom b : Int"); scan("theorem a : Prop axiom b : Int");