X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=runtime%2Fsyntax%2Farduino.yaml;h=59ba4513a15b85c13c7be134dcbebad505a0be18;hb=e420872a270e351653f62756cda24892dc1417c9;hp=e0a38dc227246260779674d862bc3f01d3292c4c;hpb=b977bf5cca84f7dc762fe8d9967831502ee5cc87;p=micro.git diff --git a/runtime/syntax/arduino.yaml b/runtime/syntax/arduino.yaml index e0a38dc2..59ba4513 100644 --- a/runtime/syntax/arduino.yaml +++ b/runtime/syntax/arduino.yaml @@ -1,43 +1,101 @@ filetype: ino -detect: +detect: filename: "\\.?ino$" rules: - - identifier.macro: "\\b[A-Z_][0-9A-Z_]+\\b" + - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" + + ## - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" - - constant: "\\b(HIGH|LOW|INPUT|OUTPUT)\\b" - - identifier.macro: "\\b(DEC|BIN|HEX|OCT|BYTE)\\b" - - constant: "\\b(PI|HALF_PI|TWO_PI)\\b" - - constant: "\\b(LSBFIRST|MSBFIRST)\\b" - - constant: "\\b(CHANGE|FALLING|RISING)\\b" - - constant: "\\b(DEFAULT|EXTERNAL|INTERNAL|INTERNAL1V1|INTERNAL2V56)\\b" + + ## Constants + - constant: "(?i)\\b(HIGH|LOW|INPUT|OUTPUT)\\b" + + ## Serial Print + - constant: "(?i)\\b(DEC|BIN|HEX|OCT|BYTE)\\b" + + ## PI Constants + - constant: "(?i)\\b(PI|HALF_PI|TWO_PI)\\b" + + ## ShiftOut + - constant: "(?i)\\b(LSBFIRST|MSBFIRST)\\b" + + ## Attach Interrupt + - constant: "(?i)\\b(CHANGE|FALLING|RISING)\\b" + + ## Analog Reference + - constant: "(?i)\\b(DEFAULT|EXTERNAL|INTERNAL|INTERNAL1V1|INTERNAL2V56)\\b" + + ## === FUNCTIONS === ## + + ## Data Types - type: "\\b(boolean|byte|char|float|int|long|word)\\b" - - statement: "\\b(case|class|default|do|double|else|false|for|if|new|null|private|protected|public|short|signed|static|String|switch|this|throw|try|true|unsigned|void|while)\\b" - - special: "\\b(goto|continue|break|return)\\b" - - statement: "\\b(abs|acos|asin|atan|atan2|ceil|constrain|cos|degrees|exp|floor|log|map|max|min|radians|random|randomSeed|round|sin|sq|sqrt|tan)\\b" - - statement: "\\b(bitRead|bitWrite|bitSet|bitClear|bit|highByte|lowByte)\\b" - - statement: "\\b(analogReference|analogRead|analogWrite)\\b" - - statement: "\\b(attachInterrupt|detachInterrupt)\\b" - - statement: "\\b(delay|delayMicroseconds|millis|micros)\\b" - - statement: "\\b(pinMode|digitalWrite|digitalRead)\\b" - - statement: "\\b(interrupts|noInterrupts)\\b" - - statement: "\\b(noTone|pulseIn|shiftIn|shiftOut|tone)\\b" - - special: "\\b(Serial|Serial1|Serial2|Serial3|begin|end|peek|read|print|println|available|flush)\\b" - - statement: "\\b(setup|loop)\\b" - - preproc: "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)" - - constant.specialChar: "'([^']|(\\\\[\"'abfnrtv\\\\]))'|'\\\\(([0-3]?[0-7]{1,2}))'|'\\\\x[0-9A-Fa-f]{1,2}'" - - preproc: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" - - constant.string: "<[^= ]*>|\"(\\\\.|[^\"])*\"" + + ## Control Structions + - statement: "\\b(case|class|default|do|double|else|false|for|if|new|null|private|protected|public|short|signed|static|String|switch|this|throw|try|true|unsigned|void|while)\\b" + - statement: "\\b(goto|continue|break|return)\\b" + + ## Math + - identifier: "\\b(abs|acos|asin|atan|atan2|ceil|constrain|cos|degrees|exp|floor|log|map|max|min|radians|random|randomSeed|round|sin|sq|sqrt|tan)\\b" + + ## Bits & Bytes + - identifier: "\\b(bitRead|bitWrite|bitSet|bitClear|bit|highByte|lowByte)\\b" + + ## Analog I/O + - identifier: "\\b(analogReference|analogRead|analogWrite)\\b" + + ## External Interrupts + - identifier: "\\b(attachInterrupt|detachInterrupt)\\b" + + ## Time + - identifier: "\\b(delay|delayMicroseconds|millis|micros)\\b" + + ## Digital I/O + - identifier: "\\b(pinMode|digitalWrite|digitalRead)\\b" + + ## Interrupts + - identifier: "\\b(interrupts|noInterrupts)\\b" + + ## Advanced I/O + - identifier: "\\b(noTone|pulseIn|shiftIn|shiftOut|tone)\\b" + + ## Serial + - identifier: "\\b(Serial|Serial1|Serial2|Serial3|begin|end|peek|read|print|println|available|flush)\\b" + + ## Structure + - identifier: "\\b(setup|loop)\\b" + + ## + - statement: "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)" + + ## GCC builtins + - constant: "(__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__)" + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + - constant.string: - start: "\"(\\\\.|[^\"])*\\\\[[:space:]]*$" - end: "^(\\\\.|[^\"])*\"" - rules: [] + start: "'" + end: "'" + skip: "\\\\." + rules: + - preproc: "..+" + - constant.specialChar: "\\\\." + + - comment: + start: "//" + end: "$" + rules: + - todo: "(TODO|XXX|FIXME):?" - - comment: "//.*" - comment: start: "/\\*" end: "\\*/" - rules: [] + rules: + - todo: "(TODO|XXX|FIXME):?" - - indent-char.whitespace: "[[:space:]]+$"