• Damien George's avatar
    py/compile: Implement PEP 526, syntax for variable annotations. · f2e267da
    Damien George authored
    This addition to the grammar was introduced in Python 3.6.  It allows
    annotating the type of a varilable, like:
    
        x: int = 123
        s: str
    
    The implementation in this commit is quite simple and just ignores the
    annotation (the int and str bits above).  The reason to implement this is
    to allow Python 3.6+ code that uses this feature to compile under
    MicroPython without change, and for users to use type checkers.
    
    In the future viper could use this syntax as a way to give types to
    variables, which is currently done in a bit of an ad-hoc way, eg
    x = int(123).  And this syntax could potentially be used in the inline
    assembler to define labels in an way that's easier to read.
    f2e267da
grammar.h 23 KB