summaryrefslogtreecommitdiff
path: root/py/lexer.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-06-02 19:37:55 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-06-03 12:32:59 +0300
commitd3439d0c6065bc60a9c4c915f4a1a3ffa796cf33 (patch)
tree0d6b55a7f6893a4d13616f72c310b4f6f532f0b0 /py/lexer.c
parent509c7a7854f24c202832d8fb1369130bf8908261 (diff)
py: Instead of having "debug on" var, have "optimization level" var.
This allows to have multiple "optimization" levels (CPython has two (-OO removes docstrings), we can have more).
Diffstat (limited to 'py/lexer.c')
-rw-r--r--py/lexer.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/py/lexer.c b/py/lexer.c
index 4a7ac071b..26993922e 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -64,12 +64,7 @@ struct _mp_lexer_t {
mp_token_t tok_cur;
};
-// debug flag for __debug__ constant
-STATIC mp_token_kind_t mp_debug_value;
-
-void mp_set_debug(bool value) {
- mp_debug_value = value ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE;
-}
+uint mp_optimise_value;
// TODO replace with a call to a standard function
bool str_strn_equal(const char *str, const char *strn, int len) {
@@ -703,7 +698,7 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
if (str_strn_equal(tok_kw[i], tok->str, tok->len)) {
if (i == ARRAY_SIZE(tok_kw) - 1) {
// tok_kw[ARRAY_SIZE(tok_kw) - 1] == "__debug__"
- tok->kind = mp_debug_value;
+ tok->kind = (mp_optimise_value == 0 ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE);
} else {
tok->kind = MP_TOKEN_KW_FALSE + i;
}