-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from ds-cbo/add-comment
Add comment statement
- Loading branch information
Showing
4 changed files
with
191 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
ts := $(shell which tree-sitter 2> /dev/null) | ||
ifeq (, ${ts}) | ||
ts := $(shell which tree-sitter-cli 2> /dev/null) | ||
CC ?= gcc | ||
|
||
TS := $(shell which tree-sitter 2>/dev/null) | ||
ifeq (, ${TS}) | ||
TS := $(shell which tree-sitter-cli 2>/dev/null) | ||
endif | ||
TSFLAGS ?= | ||
|
||
.PHONY: all | ||
all: compile | ||
|
||
.PHONY: clean | ||
clean: | ||
rm src/grammar.json src/parser.c | ||
|
||
.PHONY: generate | ||
generate: src/grammar.json src/parser.c | ||
src/grammar.json src/parser.c: grammar.js queries/highlights.scm queries/indents.scm | ||
${TS} generate ${TSFLAGS} | ||
|
||
generate: | ||
${ts} generate | ||
.PHONY: regenerate | ||
regenerate: clean generate | ||
|
||
test: generate | ||
${ts} test | ||
.PHONY: test | ||
test: src/grammar.json | ||
${TS} test | ||
|
||
format: generate | ||
${ts} test --update | ||
.PHONY: format | ||
format: src/grammar.json | ||
${TS} test --update | ||
|
||
compile: generate | ||
gcc -shared -o target/parser.so -fPIC src/parser.c -I./src | ||
.PHONY: compile | ||
compile: target/parser.so | ||
target/parser.so: src/parser.c | ||
${CC} -shared -o target/parser.so -fPIC src/parser.c -I./src | ||
|
||
check_keywords: | ||
$(shell bash scripts/test-keywords.sh) | ||
.PHONY: check_keywords | ||
check_keywords: src/grammar.json queries/highlights.scm scripts/test-keywords.sh | ||
@bash scripts/test-keywords.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ if [[ "$keywords" ]]; then | |
echo "$keywords" | ||
exit 1 | ||
fi | ||
|
||
echo "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
================================================================================ | ||
Comment on table | ||
================================================================================ | ||
|
||
COMMENT ON TABLE my_schema.my_table IS "this table is a test"; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(comment_statement | ||
(keyword_comment) | ||
(keyword_on) | ||
(keyword_table) | ||
(object_reference | ||
schema: (identifier) | ||
name: (identifier)) | ||
(keyword_is) | ||
(literal)))) | ||
|
||
================================================================================ | ||
Comment on column is null | ||
================================================================================ | ||
|
||
COMMENT ON COLUMN my_schema.my_table.my_column IS NULL; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(comment_statement | ||
(keyword_comment) | ||
(keyword_on) | ||
(keyword_column) | ||
(object_reference | ||
(object_reference | ||
(identifier) | ||
(identifier)) | ||
(identifier)) | ||
(keyword_is) | ||
(keyword_null)))) | ||
|
||
================================================================================ | ||
Comment on cast | ||
================================================================================ | ||
|
||
COMMENT ON CAST (varchar AS text) IS "convert varchar to text"; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(comment_statement | ||
(keyword_comment) | ||
(keyword_on) | ||
(cast | ||
(keyword_cast) | ||
(field | ||
(identifier)) | ||
(keyword_as) | ||
(keyword_text)) | ||
(keyword_is) | ||
(literal)))) | ||
|
||
================================================================================ | ||
Comment on materialized view | ||
================================================================================ | ||
|
||
COMMENT ON MATERIALIZED VIEW matview IS "this view is materialized"; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(comment_statement | ||
(keyword_comment) | ||
(keyword_on) | ||
(keyword_materialized) | ||
(keyword_view) | ||
(object_reference | ||
(identifier)) | ||
(keyword_is) | ||
(literal)))) | ||
|
||
================================================================================ | ||
Comment on trigger | ||
================================================================================ | ||
|
||
COMMENT ON TRIGGER on_insert ON users IS "new user has been added"; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
(program | ||
(statement | ||
(comment_statement | ||
(keyword_comment) | ||
(keyword_on) | ||
(keyword_trigger) | ||
(identifier) | ||
(keyword_on) | ||
(object_reference | ||
name: (identifier)) | ||
(keyword_is) | ||
(literal)))) |