Runtime: add method dispatch for array/string/dict/number (.len, .push, .pop, .keys, .values, .has, .toInt) Stdlib: delete global len/push/pop/keys/values/has Tests/docs/examples: migrate to method style; add tests/test_builtin_methods_style.bob All tests pass Breaking: global len/push/pop/keys/values/has removed; use methods instead Parser/AST: add class/extends/extension/super, field initializers Runtime: shared methods with this injection; classParents/classTemplates; super resolution; ownerClass/currentClass; extension lookup order Builtins: method dispatch for array/string/dict/number (.len/.push/.pop/.keys/.values/.has/.toInt); remove global forms Tests/docs/examples: add/refresh for classes, inheritance, super, polymorphism; migrate to method style; all tests pass VS Code extension: update grammar/readme/snippets for new features
273 lines
6.2 KiB
JSON
273 lines
6.2 KiB
JSON
{
|
|
"name": "Bob",
|
|
"scopeName": "source.bob",
|
|
"patterns": [
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#numbers"
|
|
},
|
|
{
|
|
"include": "#arrays"
|
|
},
|
|
{
|
|
"include": "#dictionaries"
|
|
},
|
|
{
|
|
"include": "#keywords"
|
|
},
|
|
{
|
|
"include": "#functions"
|
|
},
|
|
{
|
|
"include": "#variables"
|
|
},
|
|
{
|
|
"include": "#operators"
|
|
}
|
|
],
|
|
"repository": {
|
|
"comments": {
|
|
"patterns": [
|
|
{
|
|
"name": "comment.line.double-slash.bob",
|
|
"match": "//.*$"
|
|
},
|
|
{
|
|
"name": "comment.block.bob",
|
|
"begin": "/\\*",
|
|
"end": "\\*/"
|
|
}
|
|
]
|
|
},
|
|
"strings": {
|
|
"patterns": [
|
|
{
|
|
"name": "string.quoted.double.bob",
|
|
"begin": "\"",
|
|
"end": "\"",
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.bob",
|
|
"match": "\\\\[nt\"\\\\e]"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "string.quoted.single.bob",
|
|
"begin": "'",
|
|
"end": "'",
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.bob",
|
|
"match": "\\\\[nt'\\\\e]"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"numbers": {
|
|
"patterns": [
|
|
{
|
|
"name": "constant.numeric.integer.bob",
|
|
"match": "\\b\\d+\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.float.bob",
|
|
"match": "\\b\\d+\\.\\d+\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.binary.bob",
|
|
"match": "\\b0b[01]+\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.hex.bob",
|
|
"match": "\\b0x[0-9a-fA-F]+\\b"
|
|
}
|
|
]
|
|
},
|
|
"arrays": {
|
|
"patterns": [
|
|
{
|
|
"name": "meta.array.bob",
|
|
"begin": "\\[",
|
|
"end": "\\]",
|
|
"patterns": [
|
|
{
|
|
"include": "#expressions"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "variable.other.array-index.bob",
|
|
"match": "([a-zA-Z_][a-zA-Z0-9_]*)\\[([^\\]]+)\\]",
|
|
"captures": {
|
|
"1": { "name": "variable.other.bob" },
|
|
"2": { "name": "constant.numeric.integer.bob" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"dictionaries": {
|
|
"patterns": [
|
|
{
|
|
"name": "meta.dictionary.bob",
|
|
"begin": "\\{",
|
|
"end": "\\}",
|
|
"patterns": [
|
|
{
|
|
"name": "string.quoted.double.bob",
|
|
"begin": "\"",
|
|
"end": "\"",
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.bob",
|
|
"match": "\\\\[nt\"\\\\e]"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "keyword.operator.bob",
|
|
"match": ":"
|
|
},
|
|
{
|
|
"include": "#expressions"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "variable.other.dictionary-index.bob",
|
|
"match": "([a-zA-Z_][a-zA-Z0-9_]*)\\{([^\\}]+)\\}",
|
|
"captures": {
|
|
"1": { "name": "variable.other.bob" },
|
|
"2": { "name": "string.quoted.double.bob" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"keywords": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.control.bob",
|
|
"match": "\\b(if|else|while|do|for|break|continue|return|var|func|class|extends|extension|this|super)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.operator.bob",
|
|
"match": "\\b(and|or|not)\\b"
|
|
},
|
|
{
|
|
"name": "constant.language.bob",
|
|
"match": "\\b(true|false|none)\\b"
|
|
}
|
|
]
|
|
},
|
|
"functions": {
|
|
"patterns": [
|
|
{
|
|
"name": "entity.name.function.bob",
|
|
"match": "\\b(func)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.bob" },
|
|
"2": { "name": "entity.name.function.bob" }
|
|
}
|
|
},
|
|
{
|
|
"name": "support.function.builtin.bob",
|
|
"match": "\\b(print|assert|input|type|toString|toNumber|toInt|time|sleep|printRaw|len|push|pop|random|eval|keys|values|has)\\b"
|
|
}
|
|
]
|
|
},
|
|
"variables": {
|
|
"patterns": [
|
|
{
|
|
"name": "variable.other.bob",
|
|
"match": "\\bvar\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.bob" },
|
|
"2": { "name": "variable.other.bob" }
|
|
}
|
|
},
|
|
{
|
|
"name": "variable.other.bob",
|
|
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)(?=\\s*=)",
|
|
"captures": {
|
|
"1": { "name": "variable.other.bob" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"operators": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.operator.increment.bob",
|
|
"match": "\\+\\+|--"
|
|
},
|
|
{
|
|
"name": "keyword.operator.compound.bob",
|
|
"match": "\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|<<=|>>="
|
|
},
|
|
{
|
|
"name": "keyword.operator.comparison.bob",
|
|
"match": "==|!=|<=|>="
|
|
},
|
|
{
|
|
"name": "keyword.operator.logical.bob",
|
|
"match": "&&|\\|\\||!"
|
|
},
|
|
{
|
|
"name": "keyword.operator.bitwise.bob",
|
|
"match": "<<|>>|&|\\||\\^|~"
|
|
},
|
|
{
|
|
"name": "keyword.operator.arithmetic.bob",
|
|
"match": "\\+|-|\\*|/|%"
|
|
},
|
|
{
|
|
"name": "keyword.operator.comparison.bob",
|
|
"match": "<|>"
|
|
},
|
|
{
|
|
"name": "keyword.operator.assignment.bob",
|
|
"match": "="
|
|
},
|
|
{
|
|
"name": "keyword.operator.punctuation.bob",
|
|
"match": "\\(|\\)|\\{|\\}|\\[|\\]|,|;|\\."
|
|
},
|
|
{
|
|
"name": "keyword.operator.conditional.bob",
|
|
"match": "\\?|:"
|
|
}
|
|
]
|
|
},
|
|
"expressions": {
|
|
"patterns": [
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#numbers"
|
|
},
|
|
{
|
|
"include": "#keywords"
|
|
},
|
|
{
|
|
"include": "#functions"
|
|
},
|
|
{
|
|
"include": "#variables"
|
|
},
|
|
{
|
|
"include": "#operators"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
} |