Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various updates on grammar rules and test cases #11

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions client/syntaxes/bitbake.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
"end": "(?=\\])",
"name": "source.python"
},
{
"include": "#boolean"
},
{
"include": "#numeric"
},
Expand Down Expand Up @@ -49,46 +46,59 @@
"keywords": {
"patterns": [
{
"match": "\\s*(include|from|import|require|inherit|addtask|deltask|after|before|export|echo|if|fi|else|return|unset|print|or|fakeroot|EXPORT_FUNCTIONS|INHERIT)(?=\\s+|\\s*:)",
"match": "\\b(include|require|inherit|addtask|deltask|after|before|export|echo|if|fi|unset|print|fakeroot|EXPORT_FUNCTIONS|INHERIT)\\b",
"captures": {
"1": {
"name": "keyword.control.bb"
}
}
},
{
"match": "\\s*(def)(?=\\s+)",
"include": "#python-keywords"
},
{
"match": "\\s*(python)(?=\\s+|\\s*\\()",
"captures": {
"1": {
"name": "storage.type.function.python.bb"
}
}
},
{
"match": "\\s*(python)(?=\\s+|\\s*\\()",
"match": "\\b(bbplain|bb|self)\\b(?=\\s+|\\.)",
"captures": {
"1": {
"name": "storage.type.function.python.bb"
"name": "support.class.built-in-object.bb"
}
}
},
{
"match": "(bbplain|bb|self)(?=\\s+|\\.)",
"match": "(?<=(import|inherit|from)\\s+)([a-zA-Z_][\\w_]*)(?=\\s+)",
"name": "support.class.bb"
}
]
},
"python-keywords": {
"patterns": [
{
"match": "\\b(if|elif|else|for|while|break|continue|return|yield|try|except|finally|raise|assert|import|from|as|pass|del|with|async|await)\\b",
"captures": {
"1": {
"name": "support.class.built-in-object.bb"
"name": "keyword.control.bb"
}
}
},
{
"begin": "(?<=import|inherit)(?=\\s+)",
"end": "\\n",
"name": "support.class.bb",
"patterns": [
{
"include": "#variable-reference"
"match": "\\b(def|class|global|nonlocal|and|or|not|in|is|lambda)\\b",
"captures": {
"1": {
"name": "storage.type.function.python.bb"
}
]
}
},
{
"match": "\\b(True|False)\\b",
"name": "constant.language.python.bb"
}
]
},
Expand Down Expand Up @@ -175,9 +185,6 @@
{
"include": "#keywords"
},
{
"include": "#boolean"
},
{
"match": "(\\[)",
"name": "meta.embedded.brackets.begin.bb"
Expand Down Expand Up @@ -232,10 +239,6 @@
"parenthesis-close": {
"match": "\\)",
"name": "meta.embedded.parenthesis.close.bb"
},
"boolean": {
"match": "(?<![\\w_-])(True|False)(?![\\w_-])",
"name": "constant.language.python.bb"
}
}
}
94 changes: 81 additions & 13 deletions client/test/grammars/snaps/keywords.bb
Original file line number Diff line number Diff line change
@@ -1,4 +1,82 @@
from foo1 import bar1
# Keywords (Should target bitbake keywords only and exclude python and shell keywords)

python do_foo(){
from foo1 import bar1

if

whatif

ifnot

elif

else

for

while

break

continue

return

yield

try

except

finally

raise

assert

import

from

as

pass

del

with

async

await

def

class

global

nonlocal

and

or

not

in

is

lambda

self

True

False
}

require foo2

Expand All @@ -16,24 +94,14 @@ EXPORT_FUNCTIONS functionname

INHERIT += "autotools pkgconfig"

fakeroot python foo() {}

bbplain

bb

self
fakeroot python foo() {}

def bar3():
pass

python bar4(){}


True

False

def bar2(var1 = True):
pass
python (){}

Loading