Skip to content

WIP grammar for adoc code block #381

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
10 changes: 10 additions & 0 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@
"meta.embedded.block.cypher": "cypher"
}
},
{
"injectTo": [
"text.asciidoc"
],
"scopeName": "inline.cypher.asciidoc.codeblock",
"path": "./syntaxes/cypher.adoc.json",
"embeddedLanguages": {
"meta.embedded.block.cypher": "cypher"
}
},
{
"injectTo": [
"source.js",
Expand Down
46 changes: 46 additions & 0 deletions packages/vscode-extension/syntaxes/cypher.adoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"scopeName": "inline.cypher.asciidoc.codeblock",
"injectionSelector": "L:text.asciidoc -meta.embedded.block",
"patterns": [
{
"name": "markup.code.cypher.asciidoc",
"begin": "^\\[(source)(,|#)\\s*(?i:(cypher))([^\\]]+)*\\]\\s*$",
"beginCaptures": {
"1": {
"name": "markup.meta.attribute-list.asciidoc entity.name.function.asciidoc"
},
"3": {
"name": "markup.meta.attribute-list.asciidoc markup.heading.asciidoc"
},
"4": {
"name": "markup.meta.attribute-list.asciidoc markup.heading.asciidoc"
}
},
"patterns": [
{
"comment": "listing block",
"begin": "^(-{4,})\\s*$",
"contentName": "source.block.cypher",
"patterns": [
{
"include": "source.cypher"
}
],
"end": "^(\\1)$"
},
{
"comment": "open block",
"begin": "^(-{2})\\s*$",
"contentName": "source.embedded.cypher",
"patterns": [
{
"include": "source.cypher"
}
],
"end": "^(\\1)$"
}
],
"end": "((?<=--|\\.\\.\\.\\.)$|^\\s*$)"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[source,java]
----
import org.neo4j.cypherdsl.parser.CypherParser;

public class Demo {
public static void main(String...a) {
var node = CypherParser.parseNode("(m:Movie)");
}
}
----
Some random text


[source,cypher]
----
/* This is a
multiline comment
*/
MATCH (u1:CommerceUser{user_id:$seller_id}),
(u2:CommerceUser{user_id:$customer_id}),
p = allShortestPaths((u1)-[:PURCHASE*..10]->(u2))
WHERE u1 <> u2
WITH
// This is a single line comment
reduce(output = [], n IN relationships(p) | output + n.create_time.epochMillis ) as relsDate,
reduce(output = [], n IN nodes(p) | output + n ) as nodes,
"double quoted string" as a,
'single quoted string' as b
RETURN relsDate, nodes
LIMIT $limit
----

Some other text

[source,cypher,indent=0,tabsize=4]
----
MATCH (n) RETURN n
----