Skip to content

Commit

Permalink
Revert "Merge pull request tree-sitter#97 from matoous/md/comment-dir…
Browse files Browse the repository at this point in the history
…ectives"

This reverts commit 06432b8, reversing
changes made to dfbef73.
  • Loading branch information
matoous committed Dec 6, 2022
1 parent 06432b8 commit 87fadcc
Show file tree
Hide file tree
Showing 5 changed files with 23,473 additions and 31,372 deletions.
48 changes: 0 additions & 48 deletions corpus/source_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,54 +100,6 @@ const d
(comment)
(const_declaration (const_spec (identifier))))

================================================================================
Directive comments
================================================================================

package main

//extern test_extern
func testExtern() {}

//export text_export
func textExport() {}

//line test:123
type testLine int

//nolint:unused
type Custom int

---

(source_file
(package_clause
(package_identifier))
(comment
(directive))
(function_declaration
(identifier)
(parameter_list)
(block))
(comment
(directive))
(function_declaration
(identifier)
(parameter_list)
(block))
(comment
(directive))
(type_declaration
(type_spec
(type_identifier)
(type_identifier)))
(comment
(directive))
(type_declaration
(type_spec
(type_identifier)
(type_identifier))))

============================================
Non-ascii variable names
============================================
Expand Down
10 changes: 3 additions & 7 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,19 +895,15 @@ module.exports = grammar({
false: $ => 'false',
iota: $ => 'iota',

// https://tip.golang.org/doc/comment#syntax
directive: $ => token(/(line |extern |export |[a-z0-9]+:[a-z0-9])/),

// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
comment: $ => choice(
seq('//', $.directive, /.*/),
seq('// ', /.*/),
comment: $ => token(choice(
seq('//', /.*/),
seq(
'/*',
/[^*]*\*+([^/*][^*]*\*+)*/,
'/'
)
)
))
}
})

Expand Down
89 changes: 34 additions & 55 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -6720,64 +6720,43 @@
"type": "STRING",
"value": "iota"
},
"directive": {
"comment": {
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "(line |extern |export |[a-z0-9]+:[a-z0-9])"
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "//"
},
{
"type": "PATTERN",
"value": ".*"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "/*"
},
{
"type": "PATTERN",
"value": "[^*]*\\*+([^/*][^*]*\\*+)*"
},
{
"type": "STRING",
"value": "/"
}
]
}
]
}
},
"comment": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "//"
},
{
"type": "SYMBOL",
"name": "directive"
},
{
"type": "PATTERN",
"value": ".*"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "// "
},
{
"type": "PATTERN",
"value": ".*"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "/*"
},
{
"type": "PATTERN",
"value": "[^*]*\\*+([^/*][^*]*\\*+)*"
},
{
"type": "STRING",
"value": "/"
}
]
}
]
}
},
"extras": [
Expand Down
35 changes: 4 additions & 31 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,21 +588,6 @@
}
}
},
{
"type": "comment",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "directive",
"named": true
}
]
}
},
{
"type": "communication_case",
"named": true,
Expand Down Expand Up @@ -2618,18 +2603,6 @@
"type": "/",
"named": false
},
{
"type": "/*",
"named": false
},
{
"type": "//",
"named": false
},
{
"type": "// ",
"named": false
},
{
"type": "/=",
"named": false
Expand Down Expand Up @@ -2722,6 +2695,10 @@
"type": "chan",
"named": false
},
{
"type": "comment",
"named": true
},
{
"type": "const",
"named": false
Expand All @@ -2738,10 +2715,6 @@
"type": "defer",
"named": false
},
{
"type": "directive",
"named": true
},
{
"type": "else",
"named": false
Expand Down
Loading

0 comments on commit 87fadcc

Please sign in to comment.