Added the langium module for gitGraph

This commit is contained in:
Austin Fulbright
2024-07-21 19:50:59 -04:00
parent 3c3d28d8ee
commit 1d0e98dd62
10 changed files with 293 additions and 4 deletions

View File

@@ -1,8 +1,8 @@
import type { LangiumParser, ParseResult } from 'langium';
import type { Info, Packet, Pie } from './index.js';
import type { Info, Packet, Pie, GitGraph } from './index.js';
export type DiagramAST = Info | Packet | Pie;
export type DiagramAST = Info | Packet | Pie | GitGraph;
const parsers: Record<string, LangiumParser> = {};
const initializers = {
@@ -21,11 +21,18 @@ const initializers = {
const parser = createPieServices().Pie.parser.LangiumParser;
parsers.pie = parser;
},
gitGraph: async () => {
const { createGitGraphServices } = await import('./language/gitGraph/index.js');
const parser = createGitGraphServices().GitGraph.parser.LangiumParser;
parsers.gitGraph = parser;
},
} as const;
export async function parse(diagramType: 'info', text: string): Promise<Info>;
export async function parse(diagramType: 'packet', text: string): Promise<Packet>;
export async function parse(diagramType: 'pie', text: string): Promise<Pie>;
export async function parse(diagramType: 'gitGraph', text: string): Promise<GitGraph>;
export async function parse<T extends DiagramAST>(
diagramType: keyof typeof initializers,
text: string