From 0f9d919367ada929daa6fc8d8a176a4ba63308b2 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 3 Mar 2009 13:26:27 -0400 Subject: Added Python-style if/else expression keywords --- src/token.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/token.cc') diff --git a/src/token.cc b/src/token.cc index 6935bc7a..0a8fce7e 100644 --- a/src/token.cc +++ b/src/token.cc @@ -38,7 +38,8 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) { char c = static_cast(in.peek()); - if (c == 'a' || c == 'd' || c == 'f' || c == 'o' || c == 'n' || c == 't') { + if (c == 'a' || c == 'd' || c == 'e' || c == 'f' || + c == 'i' || c == 'o' || c == 'n' || c == 't') { length = 0; char buf[6]; @@ -64,6 +65,16 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) } break; + case 'e': + if (std::strcmp(buf, "else") == 0) { + symbol[0] = 'L'; + symbol[1] = 'S'; + symbol[2] = '\0'; + kind = KW_ELSE; + return 1; + } + break; + case 'f': if (std::strcmp(buf, "false") == 0) { kind = VALUE; @@ -72,6 +83,16 @@ int expr_t::token_t::parse_reserved_word(std::istream& in) } break; + case 'i': + if (std::strcmp(buf, "if") == 0) { + symbol[0] = 'i'; + symbol[1] = 'f'; + symbol[2] = '\0'; + kind = KW_IF; + return 1; + } + break; + case 'o': if (std::strcmp(buf, "or") == 0) { symbol[0] = '|'; -- cgit v1.2.3