diff --git a/packages/mermaid-parser/src/language/generated/grammar.ts b/packages/mermaid-parser/src/language/generated/grammar.ts index efc6ed5..ef590b1 100644 --- a/packages/mermaid-parser/src/language/generated/grammar.ts +++ b/packages/mermaid-parser/src/language/generated/grammar.ts @@ -39,7 +39,7 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm { "$type": "RuleCall", "rule": { - "$ref": "#/rules@8" + "$ref": "#/rules@7" }, "arguments": [], "cardinality": "*" @@ -61,7 +61,7 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm { "$type": "RuleCall", "rule": { - "$ref": "#/rules@8" + "$ref": "#/rules@7" }, "arguments": [], "cardinality": "*" @@ -83,7 +83,7 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm { "$type": "RuleCall", "rule": { - "$ref": "#/rules@8" + "$ref": "#/rules@7" }, "arguments": [], "cardinality": "+" @@ -106,7 +106,7 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm { "$type": "RuleCall", "rule": { - "$ref": "#/rules@8" + "$ref": "#/rules@7" }, "arguments": [], "cardinality": "*" @@ -135,7 +135,7 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm "terminal": { "$type": "RuleCall", "rule": { - "$ref": "#/rules@10" + "$ref": "#/rules@9" }, "arguments": [] } @@ -151,7 +151,7 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm "terminal": { "$type": "RuleCall", "rule": { - "$ref": "#/rules@9" + "$ref": "#/rules@8" }, "arguments": [] } @@ -182,7 +182,8 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm "$ref": "#/rules@4" }, "arguments": [] - } + }, + "cardinality": "+" }, { "$type": "Assignment", @@ -194,7 +195,8 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm "$ref": "#/rules@5" }, "arguments": [] - } + }, + "cardinality": "+" }, { "$type": "Group", @@ -206,30 +208,19 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm "terminal": { "$type": "RuleCall", "rule": { - "$ref": "#/rules@7" + "$ref": "#/rules@6" }, "arguments": [] - } + }, + "cardinality": "+" }, { - "$type": "Alternatives", - "elements": [ - { - "$type": "RuleCall", - "rule": { - "$ref": "#/rules@6" - }, - "arguments": [] - }, - { - "$type": "RuleCall", - "rule": { - "$ref": "#/rules@8" - }, - "arguments": [], - "cardinality": "+" - } - ] + "$type": "RuleCall", + "rule": { + "$ref": "#/rules@7" + }, + "arguments": [], + "cardinality": "*" } ] } @@ -261,16 +252,6 @@ export const MermaidGrammar = (): Grammar => loadedMermaidGrammar ?? (loadedMerm "fragment": false, "hidden": false }, - { - "$type": "TerminalRule", - "name": "EOF", - "definition": { - "$type": "RegexToken", - "regex": "\\\\z" - }, - "fragment": false, - "hidden": false - }, { "$type": "TerminalRule", "name": "TITLE", diff --git a/packages/mermaid-parser/src/language/grammars/common.langium b/packages/mermaid-parser/src/language/grammars/common.langium index d98184c..f1ea2eb 100644 --- a/packages/mermaid-parser/src/language/grammars/common.langium +++ b/packages/mermaid-parser/src/language/grammars/common.langium @@ -1,14 +1,13 @@ /* fragments */ fragment TITLE_AND_ACCESSIBILITIES: - accDescr=ACC_DESCR & accTitle=ACC_TITLE & title=TITLE - (EOF | NEWLINE+) + accDescr=ACC_DESCR+ & accTitle=ACC_TITLE+ & title=TITLE+ + NEWLINE* ; /* terminals */ // placeholder terminals terminal ACC_DESCR: /accDescr/; terminal ACC_TITLE: /accTitle/; -terminal EOF: /\z/; terminal TITLE: /title/; terminal NEWLINE: /\n/; diff --git a/packages/mermaid-parser/src/language/mermaid-token-builder.ts b/packages/mermaid-parser/src/language/mermaid-token-builder.ts index f7d7e89..a254452 100644 --- a/packages/mermaid-parser/src/language/mermaid-token-builder.ts +++ b/packages/mermaid-parser/src/language/mermaid-token-builder.ts @@ -1,4 +1,4 @@ -import { EOF, TokenType } from 'chevrotain'; +import { TokenType } from 'chevrotain'; import { DefaultTokenBuilder } from 'langium'; import { TerminalRule } from 'langium/lib/grammar/generated/ast'; @@ -11,17 +11,13 @@ import { export class MermiadTokenBuilder extends DefaultTokenBuilder { override buildTerminalToken(terminal: TerminalRule): TokenType { - let tokenType = super.buildTerminalToken(terminal); + const tokenType = super.buildTerminalToken(terminal); switch (tokenType.name) { case 'WHITESPACES': { tokenType.LINE_BREAKS = true; tokenType.PATTERN = removeWhitespaces; break; } - case 'EOF': { - tokenType = EOF; - break; - } case 'ACC_DESCR': { tokenType.LINE_BREAKS = true; tokenType.PATTERN = matchAccessibilityDescr;