summaryrefslogtreecommitdiffstatshomepage
path: root/unix-cpy
diff options
context:
space:
mode:
Diffstat (limited to 'unix-cpy')
-rw-r--r--unix-cpy/Makefile9
-rw-r--r--unix-cpy/main.c17
2 files changed, 23 insertions, 3 deletions
diff --git a/unix-cpy/Makefile b/unix-cpy/Makefile
index d5397dac9a..4955ea0c50 100644
--- a/unix-cpy/Makefile
+++ b/unix-cpy/Makefile
@@ -11,9 +11,16 @@ ECHO = @echo
# compiler settings
CC = gcc
-CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -Os -DUNIX #-DNDEBUG
+CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX
LDFLAGS = -lm
+#Debugging/Optimization
+ifdef DEBUG
+CFLAGS += -Og -ggdb
+else
+CFLAGS += -Os #-DNDEBUG
+endif
+
# source files
SRC_C = \
main.c \
diff --git a/unix-cpy/main.c b/unix-cpy/main.c
index ea85e32757..7d56ceaf34 100644
--- a/unix-cpy/main.c
+++ b/unix-cpy/main.c
@@ -27,16 +27,29 @@ void do_file(const char *file) {
mp_lexer_free(lex);
} else {
- // compile
+ // parse
+ qstr parse_exc_id;
+ const char *parse_exc_msg;
+ mp_parse_node_t pn = mp_parse(lex, MP_PARSE_FILE_INPUT, &parse_exc_id, &parse_exc_msg);
+
+ if (pn == MP_PARSE_NODE_NULL) {
+ // parse error
+ mp_lexer_show_error_pythonic_prefix(lex);
+ printf("%s: %s\n", qstr_str(parse_exc_id), parse_exc_msg);
+ mp_lexer_free(lex);
+ return;
+ }
- mp_parse_node_t pn = mp_parse(lex, MP_PARSE_FILE_INPUT);
mp_lexer_free(lex);
if (pn != MP_PARSE_NODE_NULL) {
//printf("----------------\n");
//parse_node_show(pn, 0);
//printf("----------------\n");
+
+ // compile
mp_obj_t module_fun = mp_compile(pn, false);
+
//printf("----------------\n");
if (module_fun == mp_const_none) {