mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
style(arch): disabled no-console for archDB, removed jison
This commit is contained in:
parent
84f1d82aac
commit
2dfadca14c
@ -1,3 +1,5 @@
|
||||
// TODO remove no-console
|
||||
/* eslint-disable no-console */
|
||||
import type {
|
||||
ArchitectureState,
|
||||
ArchitectureDB,
|
||||
@ -46,7 +48,7 @@ const clear = (): void => {
|
||||
commonClear();
|
||||
};
|
||||
|
||||
const addService = function ({id, icon, in: parent, title}: Omit<ArchitectureService, "edges">) {
|
||||
const addService = function ({ id, icon, in: parent, title }: Omit<ArchitectureService, "edges">) {
|
||||
if (state.records.registeredIds[id] !== undefined) {
|
||||
throw new Error(`The service id [${id}] is already in use by another ${state.records.registeredIds[id]}`);
|
||||
}
|
||||
@ -77,7 +79,7 @@ const addService = function ({id, icon, in: parent, title}: Omit<ArchitectureSer
|
||||
|
||||
const getServices = (): ArchitectureService[] => Object.values(state.records.services);
|
||||
|
||||
const addGroup = function ({id, icon, in: parent, title}: ArchitectureGroup) {
|
||||
const addGroup = function ({ id, icon, in: parent, title }: ArchitectureGroup) {
|
||||
// const { icon, in: inside, title } = opts;
|
||||
if (state.records.registeredIds[id] !== undefined) {
|
||||
throw new Error(`The group id [${id}] is already in use by another ${state.records.registeredIds[id]}`);
|
||||
@ -110,7 +112,7 @@ const getGroups = (): ArchitectureGroup[] => {
|
||||
};
|
||||
|
||||
const addEdge = function (
|
||||
{lhsId, rhsId, lhsDir, rhsDir, lhsInto, rhsInto, title}: ArchitectureEdge
|
||||
{ lhsId, rhsId, lhsDir, rhsDir, lhsInto, rhsInto, title }: ArchitectureEdge
|
||||
) {
|
||||
if (!isArchitectureDirection(lhsDir)) {
|
||||
throw new Error(
|
||||
|
@ -1,120 +0,0 @@
|
||||
// TODO: delete file
|
||||
%lex
|
||||
%options case-insensitive
|
||||
|
||||
%x GROUP SERVICE LINE
|
||||
%%
|
||||
|
||||
\%\%(?!\{)[^\n]* /* skip comments */
|
||||
[^\}]\%\%[^\n]* /* skip comments */
|
||||
<INITIAL,GROUP,SERVICE,LINE>[\n\r]+ { this.popState(); return 'NEWLINE'; }
|
||||
\%\%[^\n]* /* do nothing */
|
||||
[\s]+ /* skip all whitespace */
|
||||
"architecture" return 'ARCHITECTURE';
|
||||
"service" { this.begin('SERVICE'); return 'SERVICE'; }
|
||||
"group" { this.begin('GROUP'); return 'GROUP'; }
|
||||
<GROUP,SERVICE,LINE>((?!\n)\s)+ /* skip same-line whitespace */
|
||||
<GROUP,SERVICE>"in" return 'IN';
|
||||
<GROUP,SERVICE>[\w]+ return 'id';
|
||||
<GROUP,SERVICE>\([\w]*\) return 'icon';
|
||||
<GROUP,SERVICE>\[[\w ]*\] return 'title';
|
||||
[\w]+ { this.begin('LINE'); return 'id'; }
|
||||
<LINE>\([L|R|T|B]"-" return 'ARROW_LEFT_INTO';
|
||||
<LINE>[L|R|T|B]"-" return 'ARROW_LEFT';
|
||||
<LINE>"-"[L|R|T|B]\) return 'ARROW_RIGHT_INTO';
|
||||
<LINE>"-"[L|R|T|B] return 'ARROW_RIGHT';
|
||||
<LINE>[\w]+ return 'id';
|
||||
<LINE>\[[\w ]*\] return 'title';
|
||||
<INITIAL,GROUP,SERVICE,LINE><<EOF>> return 'EOF';
|
||||
|
||||
/lex
|
||||
|
||||
%start start
|
||||
|
||||
%%
|
||||
|
||||
start
|
||||
: eol start
|
||||
| ARCHITECTURE document { return $2; }
|
||||
;
|
||||
|
||||
document
|
||||
: /* empty */
|
||||
| document line
|
||||
;
|
||||
|
||||
line
|
||||
: statement eol { $$ = $1 }
|
||||
;
|
||||
|
||||
statement
|
||||
: /* empty */
|
||||
| group_statement
|
||||
| service_statement
|
||||
| line_statement
|
||||
;
|
||||
|
||||
line_statement
|
||||
: id ARROW_LEFT_INTO ARROW_RIGHT_INTO id
|
||||
{ yy.addEdge($1, $2[1], $4, $3[1], {lhsInto: true, rhsInto: true}) }
|
||||
| id ARROW_LEFT_INTO ARROW_RIGHT id
|
||||
{ yy.addEdge($1, $2[1], $4, $3[1], {lhsInto: true}) }
|
||||
| id ARROW_LEFT ARROW_RIGHT_INTO id
|
||||
{ yy.addEdge($1, $2[0], $4, $3[1], {rhsInto: true}) }
|
||||
| id ARROW_LEFT ARROW_RIGHT id
|
||||
{ yy.addEdge($1, $2[0], $4, $3[1]) }
|
||||
| id ARROW_LEFT_INTO title ARROW_RIGHT_INTO id
|
||||
{ yy.addEdge($1, $2[1], $5, $4[1], { title: $3.slice(1,-1), lhsInto: true, rhsInto: true }) }
|
||||
| id ARROW_LEFT_INTO title ARROW_RIGHT id
|
||||
{ yy.addEdge($1, $2[1], $5, $4[1], { title: $3.slice(1,-1), lhsInto: true }) }
|
||||
| id ARROW_LEFT title ARROW_RIGHT_INTO id
|
||||
{ yy.addEdge($1, $2[0], $5, $4[1], { title: $3.slice(1,-1), rhsInto: true }) }
|
||||
| id ARROW_LEFT title ARROW_RIGHT id
|
||||
{ yy.addEdge($1, $2[0], $5, $4[1], { title: $3.slice(1,-1) }) }
|
||||
;
|
||||
|
||||
group_statement
|
||||
: 'GROUP' id
|
||||
{ yy.addGroup($2) }
|
||||
| 'GROUP' id icon
|
||||
{ yy.addGroup($2, {icon: $3.slice(1,-1)}) }
|
||||
| 'GROUP' id title
|
||||
{ yy.addGroup($2, {title: $3.slice(1,-1)}) }
|
||||
| 'GROUP' id icon title
|
||||
{ yy.addGroup($2, {icon: $3.slice(1,-1), title: $4.slice(1,-1)}) }
|
||||
| 'GROUP' id 'IN' id
|
||||
{ yy.addGroup($2, {in: $4.trim()}) }
|
||||
| 'GROUP' id icon 'IN' id
|
||||
{ yy.addGroup($2, {icon: $3.slice(1,-1), in: $5.trim()}) }
|
||||
| 'GROUP' id title 'IN' id
|
||||
{ yy.addGroup($2, {title: $3.slice(1,-1), in: $5.trim()}) }
|
||||
| 'GROUP' id icon title 'IN' id
|
||||
{ yy.addGroup($2, {icon: $3.slice(1,-1), title: $4.slice(1,-1), in: $6.trim()}) }
|
||||
;
|
||||
|
||||
service_statement
|
||||
: 'SERVICE' id
|
||||
{ yy.addService($2) }
|
||||
| 'SERVICE' id icon
|
||||
{ yy.addService($2, { icon: $3.slice(1,-1) }) }
|
||||
| 'SERVICE' id title
|
||||
{ yy.addService($2, { title: $3.slice(1,-1) }) }
|
||||
| 'SERVICE' id icon title
|
||||
{ yy.addService($2, { icon: $3.slice(1,-1), title: $4.slice(1,-1) }) }
|
||||
| 'SERVICE' id 'IN' id
|
||||
{ yy.addService($2, { in: $4.trim() }) }
|
||||
| 'SERVICE' id icon 'IN' id
|
||||
{ yy.addService($2, { icon: $3.slice(1,-1), in: $5.trim() }) }
|
||||
| 'SERVICE' id title 'IN' id
|
||||
{ yy.addService($2, { title: $3.slice(1,-1), in: $5.trim() }) }
|
||||
| 'SERVICE' id icon title 'IN' id
|
||||
{ yy.addService($2, { icon: $3.slice(1,-1), title: $4.slice(1,-1), in: $6.trim() }) }
|
||||
;
|
||||
|
||||
eol
|
||||
: NEWLINE
|
||||
| ';'
|
||||
| EOF
|
||||
;
|
||||
|
||||
%%
|
Loading…
x
Reference in New Issue
Block a user