Skip to content

Commit

Permalink
Merge pull request #2 from aatauil/development
Browse files Browse the repository at this point in the history
grammar draft round 2
  • Loading branch information
aatauil authored Mar 5, 2023
2 parents de4ba48 + 8b16210 commit bd086e6
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 298 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
package-lock.json
/dist
/src/*.js
/src/parser.js
/src/parser.terms.js
/src/*.d.ts
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (C) 2021 by Achraf Atauil <[email protected]> and others
Copyright (C) 2021 by Achraf Atauil and others

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
{
"name": "codemirror-lang-sparql",
"version": "0.1.1",
"version": "0.2.0",
"description": "Sparql language support for CodeMirror",
"scripts": {
"test": "mocha test/test.js",
"prepare": "rollup -c"
"build": "lezer-generator src/syntax.grammar -o src/parser && rollup -c",
"build-debug": "lezer-generator src/syntax.grammar --names -o src/parser && rollup -c",
"test": "mocha test/test.js"
},
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"author": "Achraf Atauil",
"license": "MIT",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"types": "dist/index.d.ts",
"sideEffects": false,
"author": "Achraf Atauil",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/aatauil/codemirror-lang-sparql.git"
},
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/highlight": "^1.0.0",
Expand All @@ -29,9 +34,6 @@
"rollup-plugin-dts": "^4.0.1",
"rollup-plugin-ts": "^3.0.2",
"typescript": "^4.3.4"
},
"repository": {
"type" : "git",
"url" : "https://github.com/aatauil/codemirror-lang-sparql.git"
}
}

}
27 changes: 11 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import {parser} from "./syntax.grammar"
import {LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, foldInside, delimitedIndent} from "@codemirror/language"
import {styleTags, tags as t} from "@lezer/highlight"
import { parser } from "./syntax.grammar"
import { LRLanguage, LanguageSupport } from "@codemirror/language"
import { styleTags, tags as t } from "@lezer/highlight"

export const SparqlLanguage = LRLanguage.define({
parser: parser.configure({
props: [
indentNodeProp.add({
Application: delimitedIndent({closing: ")", align: false})
}),
foldNodeProp.add({
Application: foldInside
}),
styleTags({
Identifier: t.variableName,
Boolean: t.bool,
Comment: t.comment,
"BASE PREFIX SELECT CONSTRUCT DESCRIBE WHERE DISTINCT REDUCED STR LANG LANGMATCHES DATATYPE ASK BOUND IRI URI BNODE RAND ABS CEIL FLOOR ROUND CONCAT STRLEN UCASE LCASE ENCODE_FOR_URI CONTAINS STRSTARTS STRENDS STRBEFORE STRAFTER YEAR MONTH DAY HOURS MINUTES SECONDS TIMEZONE TZ NOW UUID STRUUID MD5 SHA1 SHA256 SHA384 SHA512 COALESCE IF STRLANG STRDT SAMETERM ISIRI ISURI ISBLANK ISLITERAL ISNUMERIC COUNT SUM MIN MAX AVG SAMPLE GROUP_CONCAT SEPARATOR SUBSTR REPLACE REGEX EXISTS NOT IN GROUP BY HAVING ORDER ASC DESC LIMIT OFFSET VALUES UNDEF UNION OPTIONAL MINUS GRAPH SERVICE SILENT FILTER BIND AS FROM NAMED LOAD INTO TO CLEAR DROP CREATE ADD MOVE COPY INSERT DATA DELETE WITH DEFAULT ALL USING": t.keyword,
"Var ObjectListPath/..": t.variableName,
String: t.string,
LineComment: t.lineComment,
"( )": t.paren
Integer: t.integer,
"Double Decimal": t.float,
"{ }": t.brace,
Langstag: t.annotation,
"TRUE FALSE": t.bool
})
]
}),
languageData: {
commentTokens: {line: ";"}
}
})

export function sparql() {
Expand Down
Loading

0 comments on commit bd086e6

Please sign in to comment.