[add] rex build jar
This commit is contained in:
parent
2078055d05
commit
c8e4f928b1
19 changed files with 8211 additions and 5119 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
data/
|
||||
node_modules/
|
||||
node_modules/
|
||||
|
|
23
README.md
23
README.md
|
@ -26,22 +26,25 @@ State is held in websocket attributes.
|
|||
#### Uses
|
||||
* https://github.com/mkslanc/ace-linters https://mkslanc.github.io/ace-linters/
|
||||
|
||||
I needed `set NODE_OPTIONS=--max_old_space_size=8192` for build to complete
|
||||
|
||||
Or `node --max-old-space-size=8192 node_modules/webpack-dev-serve
|
||||
r/bin/webpack-dev-server.js`
|
||||
|
||||
|
||||
## Related links
|
||||
java -cp org.eclipse.lemminx-uber.jar org.eclipse.lemminx.XMLServerSocketLauncher`
|
||||
|
||||
|
||||
Make a websocket server for lsp on port 3000
|
||||
https://mkslanc.github.io/ace-linters/websocket.html
|
||||
|
||||
http://localhost:3000/exampleServer
|
||||
|
||||
https://github.com/mkslanc/ace-linters/blob/c1b317e01299016ac7da6588361228637f4eac25/packages/demo/websockets-lsp/server/server.ts
|
||||
I needed `set NODE_OPTIONS=--max_old_space_size=8192` for build to complete
|
||||
|
||||
Or `node --max-old-space-size=8192 node_modules/webpack-dev-serve
|
||||
r/bin/webpack-dev-server.js`
|
||||
|
||||
### Monaco
|
||||
https://socket.dev/npm/package/monaco-editor
|
||||
|
||||
## Related links
|
||||
java -cp org.eclipse.lemminx-uber.jar org.eclipse.lemminx.XMLServerSocketLauncher`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
1
bundles/grammar/.gitignore
vendored
Normal file
1
bundles/grammar/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build
|
|
@ -1,6 +1,6 @@
|
|||
/* XQuery 4.0: An XML Query Language
|
||||
* version https://qt4cg.org/specifications/xquery-40/
|
||||
* extracted from https://qt4cg.org/specifications/xquery-40/xquery-40.html on Tue Jul 29, 2025, 19:30 (UTC+02)
|
||||
* extracted from https://qt4cg.org/specifications/xquery-40/xquery-40.html on Tue Aug 12, 2025, 21:13 (UTC+02)
|
||||
* and transformed by rexify-xquery-40.xq
|
||||
*/
|
||||
|
||||
|
@ -705,6 +705,7 @@ PostfixExpr
|
|||
| FilterExpr
|
||||
| DynamicFunctionCall
|
||||
| LookupExpr
|
||||
| MethodCall
|
||||
| FilterExprAM
|
||||
PrimaryExpr
|
||||
::= Literal
|
||||
|
@ -860,7 +861,6 @@ StringTemplate
|
|||
/* ws: explicit */
|
||||
StringTemplateVariablePart
|
||||
::= EnclosedExpr
|
||||
/* ws: explicit */
|
||||
StringConstructor
|
||||
::= '``[' StringConstructorContent ']``'
|
||||
/* ws: explicit */
|
||||
|
@ -869,13 +869,14 @@ StringConstructorContent
|
|||
/* ws: explicit */
|
||||
StringInterpolation
|
||||
::= '`' EnclosedExpr '`'
|
||||
/* ws: explicit */
|
||||
UnaryLookup
|
||||
::= Lookup
|
||||
Lookup ::= '?' KeySpecifier
|
||||
KeySpecifier
|
||||
::= NCName
|
||||
| IntegerLiteral
|
||||
| StringLiteral
|
||||
| Literal
|
||||
| ContextValueRef
|
||||
| VarRef
|
||||
| ParenthesizedExpr
|
||||
| LookupWildcard
|
||||
|
@ -891,6 +892,8 @@ PositionalArgumentList
|
|||
::= '(' PositionalArguments? ')'
|
||||
LookupExpr
|
||||
::= PostfixExpr Lookup
|
||||
MethodCall
|
||||
::= PostfixExpr '?>' NCName PositionalArgumentList
|
||||
FilterExprAM
|
||||
::= PostfixExpr '?[' Expr ']'
|
||||
AxisStep ::= ( AbbreviatedStep | FullStep ) Predicate*
|
||||
|
@ -1208,6 +1211,7 @@ URIQualifiedName
|
|||
BracedURILiteral
|
||||
::= 'Q' '{' ( PredefinedEntityRef | CharRef | [^&{}] )* '}'
|
||||
/* ws: explicit */
|
||||
EOF ::= $
|
||||
IntegerLiteral
|
||||
::= Digits
|
||||
/* ws: explicit */
|
||||
|
@ -1215,7 +1219,6 @@ Digits ::= DecDigit ( ( DecDigit | '_' )* DecDigit )?
|
|||
/* ws: explicit */
|
||||
DecDigit ::= [0-9]
|
||||
/* ws: explicit */
|
||||
EOF ::= $
|
||||
Wildcard ::= '*'
|
||||
| NCName ':*'
|
||||
| '*:' NCName
|
||||
|
|
1299
bundles/grammar/XQuery-40.ebnf.old
Normal file
1299
bundles/grammar/XQuery-40.ebnf.old
Normal file
File diff suppressed because it is too large
Load diff
4
bundles/grammar/test-java.xq
Normal file
4
bundles/grammar/test-java.xq
Normal file
|
@ -0,0 +1,4 @@
|
|||
import module namespace xq4="java:quodatum.parser.xq4";
|
||||
"C:\Users\mrwhe\git\quodatum\basex-lsp\test\sample.docs\pdfbox.xqm"
|
||||
=>unparsed-text()
|
||||
=>xq4:parseModule()
|
BIN
bundles/grammar/xq4.jar
Normal file
BIN
bundles/grammar/xq4.jar
Normal file
Binary file not shown.
1631
bundles/grammar/xq4.java
Normal file
1631
bundles/grammar/xq4.java
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
import { EditorState } from '@codemirror/state';
|
||||
import { openSearchPanel, highlightSelectionMatches,searchKeymap } from '@codemirror/search';
|
||||
import {openLintPanel, lintGutter, lintKeymap,linter,setDiagnostics} from "@codemirror/lint"
|
||||
import {openLintPanel, lintGutter, lintKeymap,linter,setDiagnostics,} from "@codemirror/lint"
|
||||
import { indentWithTab, history, defaultKeymap, historyKeymap } from '@codemirror/commands';
|
||||
import { foldGutter, indentOnInput, indentUnit, bracketMatching, foldKeymap, syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language';
|
||||
import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
|
||||
|
@ -28,10 +28,6 @@ function simpleWebSocketTransport(uri) {
|
|||
|
||||
});
|
||||
};
|
||||
function client(transport){
|
||||
return new LSPClient().connect(transport)
|
||||
};
|
||||
|
||||
|
||||
const baseExts = [
|
||||
lineNumbers(),
|
||||
|
@ -80,6 +76,10 @@ function createEditorState(initialContents, extensions,options = {}) {
|
|||
function createEditorView(state, parent) {
|
||||
return new EditorView({ state, parent });
|
||||
}
|
||||
class xqLinter {
|
||||
constructor(parameters) {
|
||||
this.fred=parameters;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export { createEditorState, createEditorView, openSearchPanel,openLintPanel, languageServerSupport, baseExts ,client, simpleWebSocketTransport,linter, LSPPlugin,setDiagnostics};
|
||||
export { createEditorState, createEditorView, openSearchPanel,openLintPanel, languageServerSupport, baseExts , simpleWebSocketTransport,linter, LSPPlugin,setDiagnostics,xqLinter,LSPClient};
|
27
package-lock.json
generated
27
package-lock.json
generated
|
@ -13,7 +13,9 @@
|
|||
"@codemirror/lsp-client": "^6.0.0",
|
||||
"@codemirror/search": "^6.2.3",
|
||||
"@codemirror/theme-one-dark": "^6.1.0",
|
||||
"@codemirror/view": "^6.6.0"
|
||||
"@codemirror/view": "^6.6.0",
|
||||
"ace-builds": "^1.43.2",
|
||||
"ace-linters": "^1.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
|
@ -708,6 +710,23 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ace-builds": {
|
||||
"version": "1.43.2",
|
||||
"resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.43.2.tgz",
|
||||
"integrity": "sha512-3wzJUJX0RpMc03jo0V8Q3bSb/cKPnS7Nqqw8fVHsCCHweKMiTIxT3fP46EhjmVy6MCuxwP801ere+RW245phGw==",
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/ace-linters": {
|
||||
"version": "1.8.3",
|
||||
"resolved": "https://registry.npmjs.org/ace-linters/-/ace-linters-1.8.3.tgz",
|
||||
"integrity": "sha512-bLz4j8Qe8OFyym4Eb1CqMFPgR4if3M1RdNReXhBR9tNHEFYRUwAV3kMdHDT740DwljhPjFdwT2b9ighou+rBuA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vscode-languageserver-protocol": "^3.17.5",
|
||||
"vscode-languageserver-textdocument": "^1.0.12",
|
||||
"vscode-languageserver-types": "^3.17.5"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.15.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
|
||||
|
@ -1375,6 +1394,12 @@
|
|||
"vscode-languageserver-types": "3.17.5"
|
||||
}
|
||||
},
|
||||
"node_modules/vscode-languageserver-textdocument": {
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz",
|
||||
"integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vscode-languageserver-types": {
|
||||
"version": "3.17.5",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz",
|
||||
|
|
22
package.json
22
package.json
|
@ -1,27 +1,29 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "^6.1.2",
|
||||
|
||||
"@codemirror/lang-javascript": "^6.1.1",
|
||||
"@codemirror/lang-markdown": "^6.3.4",
|
||||
"@codemirror/lang-xml": "^6.1.0",
|
||||
"@codemirror/lint": "^6.8.5",
|
||||
"@codemirror/lsp-client": "^6.0.0",
|
||||
"@codemirror/search": "^6.2.3",
|
||||
"@codemirror/theme-one-dark": "^6.1.0",
|
||||
"@codemirror/view": "^6.6.0",
|
||||
"@codemirror/lint": "^6.8.5",
|
||||
"@codemirror/lang-markdown": "^6.3.4",
|
||||
"@codemirror/lang-javascript": "^6.1.1",
|
||||
"@codemirror/lang-xml": "^6.1.0"
|
||||
"ace-builds": "^1.43.2",
|
||||
"ace-linters": "^1.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"minify": "^9.1.0",
|
||||
"rollup": "4",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@rollup/plugin-typescript": "^12.1.4",
|
||||
"minify": "^9.1.0",
|
||||
"rollup": "4",
|
||||
"rollup-plugin-tla": "^0.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup src/index.js -m true -f iife -o dist/cm6.bundle.js -p node-resolve,tla --output.name cm6",
|
||||
"build-cm": "rollup bundles/src/lsp.js -m true -f iife -o webapp/static/clients/codemirror/lsp.bundle.js -p node-resolve,tla --output.name lsp",
|
||||
"min-cm": "cd webapp/static/clients/codemirror && npx minify lsp.bundle.js > lsp.bundle.min.js ",
|
||||
"min": "cd dist && npx minify cm6.bundle.js > cm6.bundle.min.js && npx minify lsp.bundle.js > lsp.bundle.min.js"
|
||||
"min-cm": "cd webapp/static/clients/codemirror && npx minify lsp.bundle.js > lsp.bundle.min.js ",
|
||||
"min": "cd dist && npx minify cm6.bundle.js > cm6.bundle.min.js && npx minify lsp.bundle.js > lsp.bundle.min.js",
|
||||
"javac":"cd bundles/grammar && javac -cp %BASEX12%\\BaseX.jar -d build xq4.java && cd build && jar cf ../xq4.jar . "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
67
scripts/postutil.xqm
Normal file
67
scripts/postutil.xqm
Normal file
|
@ -0,0 +1,67 @@
|
|||
(:~ post utils :)
|
||||
module namespace qform = 'urn:quodatum:http.form';
|
||||
|
||||
(:~ post form data in $fields to $url RR style
|
||||
@param $url http server target
|
||||
@param $fields map if key starts @ value is file path to upload
|
||||
:)
|
||||
declare function qform:post-form($fields as map(*), $url as xs:string)
|
||||
as item(){
|
||||
let $names:= map:keys($fields)
|
||||
|
||||
let $req:=<http:request method='POST'>
|
||||
<http:multipart media-type='multipart/form-data'>{
|
||||
for $name in $names
|
||||
return (
|
||||
if(starts-with($name,"@"))
|
||||
then let $file:=$fields($name)
|
||||
return <http:header name='content-disposition'
|
||||
value='form-data; name="{substring($name,2)}"; filename="{file:name($file)}"'/>
|
||||
else <http:header name='content-disposition'
|
||||
value='form-data; name="{$name}";'/>,
|
||||
<http:body media-type='application/octet-stream'/>
|
||||
)
|
||||
}</http:multipart>
|
||||
</http:request>
|
||||
let $result:= http:send-request($req=>trace("REQ"), $url,
|
||||
for $name in $names
|
||||
return if(starts-with($name,"@"))
|
||||
then unparsed-text($fields($name))=>trace("EE")
|
||||
else $fields($name)
|
||||
)
|
||||
return if($result[1]/@status eq "200")
|
||||
then $result[2]
|
||||
else error(xs:QName("qform:post-form"),$result[1]/@message)
|
||||
};
|
||||
|
||||
(:~ post json data in $fields to $url OLLAMA style
|
||||
:)
|
||||
declare function qform:post-json($fields as map(*), $url as xs:string)
|
||||
as item(){
|
||||
|
||||
let $req:=<http:request method='POST' override-media-type='text/plain'>
|
||||
<http:body media-type='application/json'/>
|
||||
</http:request>
|
||||
let $body:= serialize($fields,map{"method":"json"})
|
||||
let $result:= http:send-request($req, $url, $body)
|
||||
return if($result[1]/@status eq "200")
|
||||
then $result[2]
|
||||
else error(xs:QName("qform:post-json"),$result[1]/@message)
|
||||
};
|
||||
(:~ post json data in $fields to $url mermaid style
|
||||
:)
|
||||
declare function qform:post-text($text as xs:string, $url as xs:string)
|
||||
as item(){
|
||||
let $req:=<http:request method='POST'>
|
||||
<http:body media-type='text/plain'/>
|
||||
</http:request>
|
||||
return http:send-request($req, $url, $text)
|
||||
=>qform:check("qform:post-text")
|
||||
};
|
||||
|
||||
declare function qform:check($result as item()+, $code as xs:string)
|
||||
as item(){
|
||||
if($result[1]/@status eq "200")
|
||||
then $result[2]
|
||||
else error(xs:QName($code),$result[1]/@message)
|
||||
};
|
31
scripts/rex.xq
Normal file
31
scripts/rex.xq
Normal file
|
@ -0,0 +1,31 @@
|
|||
import module namespace qform = 'urn:quodatum:http.form' at "postutil.xqm";
|
||||
declare variable $REX:="https://www.bottlecaps.de/rex/";
|
||||
|
||||
declare function local:resolve($path as xs:string)
|
||||
as xs:string{
|
||||
file:resolve-path($path,file:base-dir())
|
||||
};
|
||||
declare function local:rex($ebnf,$opts as map(*))
|
||||
{
|
||||
let $xq:= qform:post-form(map:put($opts,"@input",$ebnf),$REX)
|
||||
let $write:=if($xq instance of xs:base64Binary)
|
||||
then file:write-binary#2
|
||||
else file:write-text#2
|
||||
return $write($opts?dest,$xq)
|
||||
};
|
||||
|
||||
let $target:={
|
||||
"xquery": {
|
||||
"dest":local:resolve("../webapp/lsp/xq4.xqm"),
|
||||
"command": "-lalr 2 -tree -name quodatum.parser.xq4 -xquery"},
|
||||
|
||||
"basex" : {
|
||||
"dest": local:resolve("../bundles/grammar/xq4.java"),
|
||||
"command": "-lalr 2 -tree -name quodatum.parser.xq4 -java -basex"}
|
||||
|
||||
}
|
||||
|
||||
let $ebnf:=local:resolve("../bundles/grammar/XQuery-40.ebnf")
|
||||
|
||||
return local:rex($ebnf,$target("basex"))
|
||||
|
|
@ -2,4 +2,6 @@ import module namespace pos="lsp/position" at "../webapp/lsp/position.xqm";
|
|||
let $text:=unparsed-text("sample.docs/pdfbox.xqm")
|
||||
let $nl:= index-of(string-to-codepoints($text),10)
|
||||
|
||||
return pos:lineAt($nl,18752)
|
||||
return (
|
||||
pos:toPosition($text,10744),pos:toPosition($text,10745)
|
||||
)
|
10172
webapp/lsp/xq4.xqm
10172
webapp/lsp/xq4.xqm
File diff suppressed because it is too large
Load diff
|
@ -31438,7 +31438,13 @@ ${text}</tr>
|
|||
function createEditorView(state, parent) {
|
||||
return new EditorView({ state, parent });
|
||||
}
|
||||
class xqLinter {
|
||||
constructor(parameters) {
|
||||
this.fred=parameters;
|
||||
}
|
||||
}
|
||||
|
||||
exports.LSPClient = LSPClient;
|
||||
exports.LSPPlugin = LSPPlugin;
|
||||
exports.baseExts = baseExts;
|
||||
exports.client = client;
|
||||
|
@ -31450,6 +31456,7 @@ ${text}</tr>
|
|||
exports.openSearchPanel = openSearchPanel;
|
||||
exports.setDiagnostics = setDiagnostics;
|
||||
exports.simpleWebSocketTransport = simpleWebSocketTransport;
|
||||
exports.xqLinter = xqLinter;
|
||||
|
||||
return exports;
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,7 @@ window.addEventListener('load', () => {
|
|||
|
||||
const view = lsp.createEditorView(undefined, document.getElementById("editor"));
|
||||
let doc = `3+1`;
|
||||
let client;
|
||||
var client;
|
||||
|
||||
|
||||
// Save content to localStorage when the page is about to unload
|
||||
|
@ -66,7 +66,7 @@ function connect() {
|
|||
lsp.simpleWebSocketTransport(server)
|
||||
.then(transport => {
|
||||
transport.subscribe(incoming);
|
||||
client = lsp.client(transport);
|
||||
client = new lsp.LSPClient().connect(transport);
|
||||
let plugin=lsp.languageServerSupport(client,file,"xquery")
|
||||
const doc = view.state.doc.toString();
|
||||
const state = lsp.createEditorState(doc, [...lsp.baseExts, plugin]);
|
||||
|
@ -89,13 +89,14 @@ function incoming(msg) {
|
|||
};
|
||||
function diags(params){
|
||||
console.log("--",params)
|
||||
let plugin= lsp.LSPPlugin.get(view)
|
||||
let plugin= lsp.LSPPlugin.get(view);
|
||||
const severities=["error" , "hint" ,"info" ,"warning"]
|
||||
//
|
||||
const diagnostics = params.diagnostics
|
||||
.map(({ range, message, severity }) => ({
|
||||
from: plugin.fromPosition( range.start,view.state.doc),
|
||||
to: plugin.fromPosition( range.end,view.state.doc),
|
||||
severity: 'error',
|
||||
|
||||
severity: severities[severity -1],
|
||||
message,
|
||||
}))
|
||||
.filter(
|
||||
|
|
Loading…
Add table
Reference in a new issue