Skip to content

Commit

Permalink
Generate grammar comments
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Jan 8, 2024
1 parent 2ca2b3a commit e1c45e6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions examples/domainmodel/src/language-server/domain-model.langium
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Entity:
(features+=Feature)*
'}';

/**
* This comment should be generated into the grammar!
*/
Feature:
(many?='many')? name=ID ':' type=[Type:QualifiedName];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ export const DomainModelGrammar = (): Grammar => loadedDomainModelGrammar ?? (lo
"fragment": false,
"hiddenTokens": [],
"parameters": [],
"wildcard": false
"wildcard": false,
"$comment": "/**\\r\\n * This comment should be generated into the grammar!\\r\\n */"
},
{
"$type": "ParserRule",
Expand Down
1 change: 1 addition & 0 deletions packages/langium-cli/src/generator/grammar-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function serializeGrammar(services: LangiumServices, grammars: Grammar[],
};
const serializedGrammar = services.serializer.JsonSerializer.serialize(grammar, {
space: production ? undefined : 2,
comments: true,
uriConverter
});
// The json serializer returns strings with \n line delimiter by default
Expand Down
11 changes: 6 additions & 5 deletions packages/langium/src/grammar/langium-grammar.langium
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/******************************************************************************
* Copyright 2021 TypeFox GmbH
* This program and the accompanying materials are made available under the
* terms of the MIT License, which is available in the project root.
******************************************************************************/
// ******************************************************************************
// Copyright 2021 TypeFox GmbH
// This program and the accompanying materials are made available under the
// terms of the MIT License, which is available in the project root.
// *****************************************************************************

grammar LangiumGrammar

entry Grammar:
Expand Down

0 comments on commit e1c45e6

Please sign in to comment.