1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
require c-uchar
syntax .python-esc
# TODO: \N{name}
state esc special
char "abfnrtv'\\\"" END special
char 0-7 oct1
char x hex0
char u .c-uchar4:END special
char U .c-uchar8:END special
noeat END
state oct1 special
char 0-7 oct2
noeat END
state oct2 special
char 0-7 END special
noeat END
state hex0 special
char 0-9a-fA-F hex1
noeat END
state hex1 special
char 0-9a-fA-F END special
noeat END
syntax python
state start code
char # comment
str '"""' longdq
str "'''" longsq
char '"' dq
char "'" sq
# TODO: [uU][rR]" [uU]" [rR]" [bB]" [bB][rR]"
char -b a-zA-Z_ ident
char 0 zero
char 1-9 dec
char . dot
char " \t\f\r\n" whitespace
eat this
state comment
char "\n" start
eat this
state longdq string
str '"""' start string
char -b "\\" .python-esc:this
eat this
state longsq string
str "'''" start string
char -b "\\" .python-esc:this
eat this
state dq string
char "\"" start string
char "\n" start
char -b "\\" .python-esc:this
eat this
state sq string
char "'" start string
char "\n" start
char -b "\\" .python-esc:this
eat this
state ident
char -b a-zA-Z_0-9 this
inlist keyword start
inlist constant start
noeat start
state zero numeric
char bB bin
char oO oct
char xX hex
char 0 dec-zero
char . float
char eE exponent
noeat int-suffix
state bin numeric
char 01 this
noeat int-suffix
state oct numeric
char 0-7 this
noeat int-suffix
state dec numeric
char 0-9 this
char eE exponent
char . float
noeat int-suffix
state dec-zero numeric
char 0 this
char eE exponent
char . float
# TODO: digits 1-9 are allowed here but only if the number becomes a float
noeat int-suffix
state hex numeric
char 0-9a-fA-F this
noeat int-suffix
state int-suffix code
# TODO: Remove long int suffixes? (removed in Python 3)
char lL int-end numeric
char jJ float-end numeric
noeat int-end
state int-end error
char a-zA-Z0-9_ this
noeat start
state float numeric
char 0-9 this
char eE exponent
noeat float-suffix
state exponent numeric
char +- exponent-sign
char 0-9 exponent-digit
recolor error 1
noeat float-end
state exponent-sign numeric
char 0-9 exponent-digit
recolor error 2
noeat float-end
state exponent-digit numeric
char 0-9 this
noeat float-suffix
state float-suffix code
char jJ float-end numeric
noeat int-end
state float-end error
char a-zA-Z_ this
noeat start
state whitespace
char " \t\f\r\n" this
char . whitespace-dot
noeat start
state whitespace-dot code
char 0-9 dot-float
noeat start
state dot-float numeric
recolor numeric 2
noeat float
state dot code
char 0-9 this error
noeat start
list keyword \
and as assert break class continue def del elif else except exec \
finally for from global if import in is lambda not or pass print \
raise return try while with yield
list constant \
None False True
|