Add comments to javascript grammar
This commit is contained in:
parent
c2abfd2d03
commit
68c26a06b1
2 changed files with 12 additions and 1 deletions
|
|
@ -34,6 +34,7 @@ namespace tree_sitter_examples {
|
|||
|
||||
// Statements
|
||||
{ "statement", choice({
|
||||
sym("comment"),
|
||||
sym("statement_block"),
|
||||
sym("if_statement"),
|
||||
sym("switch_statement"),
|
||||
|
|
@ -176,6 +177,7 @@ namespace tree_sitter_examples {
|
|||
{ "true", str("true") },
|
||||
{ "false", str("false") },
|
||||
|
||||
{ "comment", pattern("//[^\n]*") },
|
||||
{ "_terminator", pattern("[;\n]") },
|
||||
{ "string", pattern("\"([^\"]|\\\\\")+\"") },
|
||||
{ "identifier", pattern("\\a[\\w_$]*") },
|
||||
|
|
|
|||
|
|
@ -59,4 +59,13 @@ print(object[propertyName()]);
|
|||
(identifier)
|
||||
(property_access (identifier) (function_call (identifier))))))
|
||||
|
||||
|
||||
==========================================
|
||||
parses comments
|
||||
==========================================
|
||||
// this is another comment
|
||||
stuff(); // this is a comment
|
||||
---
|
||||
(program
|
||||
(comment)
|
||||
(expression_statement (function_call (identifier)))
|
||||
(comment))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue