Compare commits

...

3 commits

Author SHA1 Message Date
Bruno BELANYI bca4c8d312 Release 0.1.2 2024-04-08 08:48:54 +01:00
Bruno BELANYI 540f28e55e Add block comments 2024-04-08 08:48:10 +01:00
Bruno BELANYI f76248b670 Fix line comments syntax
Don't write parsers after midnight kids.

For the explanation: I mixed up the syntax bits between Blueprint and
textual protocol buffers...
2024-04-08 08:41:25 +01:00
7 changed files with 2553 additions and 1933 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "tree-sitter-blueprint"
description = "Blueprint grammar for the tree-sitter parsing library"
version = "0.1.1"
version = "0.1.2"
keywords = ["incremental", "parsing", "android", "blueprint"]
categories = ["parsing", "text-editors"]
repository = "https://git.belanyi.fr/ambroisie/tree-sitter-blueprint"

View file

@ -11,7 +11,8 @@ module.exports = grammar({
extras: ($) => [
/\s+/,
$.comment,
$.line_comment,
$.block_comment,
],
rules: {
@ -22,7 +23,9 @@ module.exports = grammar({
$.module,
),
comment: (_) => seq("#", /.*/),
line_comment: (_) => seq("//", /.*/),
block_comment: (_) => seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, '/'),
// Definitions {{{

View file

@ -1,6 +1,6 @@
{
"name": "tree-sitter-blueprint",
"version": "0.1.1",
"version": "0.1.2",
"description": "Blueprint grammar for tree-sitter",
"main": "bindings/node",
"keywords": [

27
src/grammar.json generated
View file

@ -21,12 +21,12 @@
}
]
},
"comment": {
"line_comment": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "#"
"value": "//"
},
{
"type": "PATTERN",
@ -34,6 +34,23 @@
}
]
},
"block_comment": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "/*"
},
{
"type": "PATTERN",
"value": "[^*]*\\*+([^/*][^*]*\\*+)*"
},
{
"type": "STRING",
"value": "/"
}
]
},
"assignment": {
"type": "SEQ",
"members": [
@ -935,7 +952,11 @@
},
{
"type": "SYMBOL",
"name": "comment"
"name": "line_comment"
},
{
"type": "SYMBOL",
"name": "block_comment"
}
],
"conflicts": [],

25
src/node-types.json generated
View file

@ -168,12 +168,12 @@
}
},
{
"type": "boolean_literal",
"type": "block_comment",
"named": true,
"fields": {}
},
{
"type": "comment",
"type": "boolean_literal",
"named": true,
"fields": {}
},
@ -259,6 +259,11 @@
]
}
},
{
"type": "line_comment",
"named": true,
"fields": {}
},
{
"type": "list_expression",
"named": true,
@ -632,10 +637,6 @@
"type": "\"",
"named": false
},
{
"type": "#",
"named": false
},
{
"type": "(",
"named": false
@ -652,6 +653,18 @@
"type": "-",
"named": false
},
{
"type": "/",
"named": false
},
{
"type": "/*",
"named": false
},
{
"type": "//",
"named": false
},
{
"type": ":",
"named": false

4318
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -2,33 +2,122 @@
Empty comment
================================================================================
#
//
--------------------------------------------------------------------------------
(source_file
(comment))
(line_comment))
================================================================================
Single comment
================================================================================
# This is a comment
// This is a comment
--------------------------------------------------------------------------------
(source_file
(comment))
(line_comment))
================================================================================
Multiple comments
================================================================================
# This is a comment
# This is a second comment
// This is a comment
// This is a second comment
--------------------------------------------------------------------------------
(source_file
(comment)
(comment))
(line_comment)
(line_comment))
================================================================================
Empty block comment
================================================================================
/**/
--------------------------------------------------------------------------------
(source_file
(block_comment))
================================================================================
Whitespace block comment
================================================================================
/* */
--------------------------------------------------------------------------------
(source_file
(block_comment))
================================================================================
Block comment
================================================================================
/* This is a comment */
--------------------------------------------------------------------------------
(source_file
(block_comment))
================================================================================
Block comment with slashes
================================================================================
/* /// */
--------------------------------------------------------------------------------
(source_file
(block_comment))
================================================================================
Block comment with asterisks
================================================================================
/* *** */
--------------------------------------------------------------------------------
(source_file
(block_comment))
================================================================================
Block comment is not recursive
================================================================================
/* /* */
--------------------------------------------------------------------------------
(source_file
(block_comment))
================================================================================
Unterminated comment
================================================================================
/*
--------------------------------------------------------------------------------
(source_file
(ERROR))
================================================================================
Comment end-delimiter only
================================================================================
*/
--------------------------------------------------------------------------------
(source_file
(ERROR
(UNEXPECTED '*')))