Skip to content
Snippets Groups Projects
Select Git revision
  • d4189d2f2e1e3e807aaf193b0f12219e0b108734
  • master default protected
  • fix-warnings
  • tvbgone-fixes
  • genofire/ble-follow-py
  • schneider/ble-stability-new-phy-adv
  • schneider/ble-stability
  • msgctl/gfx_rle
  • schneider/ble-stability-new-phy
  • add_menu_vibration
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
36 results

version-image.py

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    parsehelper.c 1.98 KiB
    // these functions are separate from parse.c to keep parser independent of mp_obj_t
    
    #include <stdint.h>
    #include <stdio.h>
    
    #include "misc.h"
    #include "mpconfig.h"
    #include "qstr.h"
    #include "lexer.h"
    #include "parse.h"
    #include "obj.h"
    #include "parsehelper.h"
    
    #define STR_MEMORY "parser could not allocate enough memory"
    #define STR_UNEXPECTED_INDENT "unexpected indent"
    #define STR_UNMATCHED_UNINDENT "unindent does not match any outer indentation level"
    #define STR_INVALID_SYNTAX "invalid syntax"
    
    void mp_parse_show_exception(mp_lexer_t *lex, mp_parse_error_kind_t parse_error_kind) {
        printf("  File \"%s\", line %d, column %d\n", qstr_str(mp_lexer_source_name(lex)), mp_lexer_cur(lex)->src_line, mp_lexer_cur(lex)->src_column);
        switch (parse_error_kind) {
            case MP_PARSE_ERROR_MEMORY:
                printf("MemoryError: %s\n", STR_MEMORY);
                break;
    
            case MP_PARSE_ERROR_UNEXPECTED_INDENT:
                printf("IndentationError: %s\n", STR_UNEXPECTED_INDENT);
                break;
    
            case MP_PARSE_ERROR_UNMATCHED_UNINDENT:
                printf("IndentationError: %s\n", STR_UNMATCHED_UNINDENT);
                break;
    
            case MP_PARSE_ERROR_INVALID_SYNTAX:
            default:
                printf("SyntaxError: %s\n", STR_INVALID_SYNTAX);
                break;
        }
    }
    
    mp_obj_t mp_parse_make_exception(mp_parse_error_kind_t parse_error_kind) {
        // TODO add source file and line number to exception?
        switch (parse_error_kind) {
            case MP_PARSE_ERROR_MEMORY:
                return mp_obj_new_exception_msg(&mp_type_MemoryError, STR_MEMORY);
    
            case MP_PARSE_ERROR_UNEXPECTED_INDENT:
                return mp_obj_new_exception_msg(&mp_type_IndentationError, STR_UNEXPECTED_INDENT);
    
            case MP_PARSE_ERROR_UNMATCHED_UNINDENT:
                return mp_obj_new_exception_msg(&mp_type_IndentationError, STR_UNMATCHED_UNINDENT);
    
            case MP_PARSE_ERROR_INVALID_SYNTAX:
            default:
                return mp_obj_new_exception_msg(&mp_type_SyntaxError, STR_INVALID_SYNTAX);
        }
    }