Skip to content

Commit

Permalink
rsdlEditor: build parser from lezer grammar (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfhandl authored Aug 4, 2022
1 parent 5e04ab7 commit 10b5343
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 40 deletions.
9 changes: 5 additions & 4 deletions tools/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"hbenl.vscode-mocha-test-adapter",
]
"recommendations": [
"esbenp.prettier-vscode",
"hbenl.vscode-mocha-test-adapter",
"tamuratak.vscode-lezer"
]
}
25 changes: 25 additions & 0 deletions tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tools/rsdlEditor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rimraf dist && rollup --config rollup.config.cjs"
"generate-rsdl-parser": "lezer-generator ./src/lang-rsdl/lezer-rsdl.grammar -o src/lang-rsdl/parser.js --noTerms",
"build": "npm run generate-rsdl-parser && rollup --config rollup.config.cjs"
},
"author": "",
"license": "Apache-2.0",
Expand All @@ -15,6 +16,7 @@
"codemirror": "^6"
},
"devDependencies": {
"@lezer/generator": "^1.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^8.3.3",
"@tsconfig/recommended": "^1.0.1",
Expand Down
36 changes: 1 addition & 35 deletions tools/rsdlEditor/src/lang-rsdl/lang.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LRParser } from "@lezer/lr";
import {
LRLanguage,
indentNodeProp,
Expand All @@ -10,40 +9,7 @@ import {
import { styleTags, tags } from "@lezer/highlight";
import { ifNotIn, completeFromList } from "@codemirror/autocomplete";
import { snippets } from "./snippets";

// This file was generated by lezer-generator. You probably shouldn't edit it.
const spec_Identifier = {
__proto__: null,
type: 12,
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-E7ZOOQO-E7^-E7^OOQO,59y,59yOOQO-E7]-E7]",
stateData:
"*e~O!VOSPOS~ORQOUTOvUO!^PO~ORQOUTOvUO!]VO!^PO~ORYO~ORYOW[O~ORQOUTOvUO!]^O!^PO~OW_O~OR`OZeOefOjgOyhO{hO!`bOSwP~OWjO~OR`OZeOefOjgO!`bO~O]lO~ORmOanO~OR`O~ORqO~ORrO~OStO~OSvO~ORmOanO!ZxO~O!X{O]`XS`X!Y`X![`X!]`X!_`X~O]}O~O]!OO~O!^!PO~OW!SO~OS!TO~O!Y!UOS_X![_X!]_X!__X~OR!WOa!WO~O!X{O]`aS`a!Y`a![`a!]`a!_`a~On!ZOo!ZOp!ZOr!YOs!ZO~O!Z!^O~P&wOR`O!]gP~O]!cO~OR!dOSzP~O![!fO~Or!gO!X!iO~O![tP~P&wO]!lO~O!_!mO!]gX~O!]!oO~OR!qOSzX~OS!sO~Or!gOSqa![qa!_qa~Or!gO~O!_!vO![tX~O![!xO~O!_!mO!]ga~OR!qOSza~Or!gOSqi![qi!_qi~O!_!vO![ta~O",
goto: "&Q!XPPPPP!YP!`P!i!pP!uP#R#_#hP#_#r!pP#x$O$R!pP!p$X$bPPP$gPP$l!YP$o$uP$yP!Y$|%W%^%d%n%tPPP%zXQOPSWQZTQ]URshSd[jRk_Vc[_jUa[_jQpeT!`!P!mQzlQ!_!OQ!p!cR!y!lWyl!O!c!lR!VxQobZwlx!O!c!lXyl!O!c!lQ!QqR!RrR!b!PQ!a!PR!z!mQ!]}Q!j!^R!}!vV![}!^!vV!Z}!^!vR!k!^Qi[RujTd[jR!e!SQSOQWPTXSWQ|mR!X|Q!n!aR!{!nQ!h!YS!t!h!uR!u!iQ!w!jR#O!wQ!r!dR!|!rXROPSW",
nodeNames:
"⚠ LineComment Program Identifier } TypeDefinition type DefinitionName { TypeBodyDefinition FieldDefinition key VariableName : FieldType RequiredType TypeRefName CapitalIdentifier OptionalType MultiValuedType FunctionDefinition function FormalParameters CommaSepParams FormalParameter ActionDefinition action AnnotationDefinition AnnotationValue Literal true false null NumberLiteral Digits StringLiteral CommaSepAnnotationValues ServiceDefinition service ServiceBodyDefinition EnumDefinition enum SpaceSepIds flags Application",
maxTerm: 62,
skippedNodes: [0, 1],
repeatNodeCount: 6,
tokenData:
"&W~RfXY!gYZ!g]^!gpq!grs!xst#ptu#{xy$ayz$f|}$k!O!P$p!Q![$u![!]$}!a!b%S!b!c%X!c!}%^!}#O%r#P#Q%w#R#S#{#T#o#{#o#p%|#q#r&R~!lS!V~XY!gYZ!g]^!gpq!g~!{UOY!xZr!xrs#_s#O!x#O#P#d#P~!x~#dOs~~#gROY!xYZ!xZ~!x~#uQP~OY#pZ~#p~$QTR~tu#{!Q![#{!c!}#{#R#S#{#T#o#{~$fO!^~~$kO!]~~$pO!_~~$uO!X~~$zPr~!Q![$u~%SO]~~%XO!Y~~%^O!`~~%cTa~tu%^!Q![%^!c!}%^#R#S%^#T#o%^~%wO!Z~~%|O![~~&ROW~~&WOS~",
tokenizers: [0],
topRules: { Program: [0, 2] },
specialized: [{ term: 3, get: (value) => spec_Identifier[value] || -1 }],
tokenPrec: 0,
});
import { parser } from "./parser";

const rsdlLanguage = LRLanguage.define({
parser: parser.configure({
Expand Down
18 changes: 18 additions & 0 deletions tools/rsdlEditor/src/lang-rsdl/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 10b5343

Please sign in to comment.