Skip to content

How to use ValueConverter service for converting e.g. ID and STRING values #147

Answered by msujew
hallvard asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @hallvard, I guess we f'd something up. The default value converter will strip the quotes if you rename the STRING terminal to string (even though it will show a warning). The reason for that is this code:

https://github.com/langium/langium/blob/fbdef5d08b059e182a86db60dc06ef46e44d35e5/packages/langium/src/parser/value-converter.ts#L32-L36

On a more general note: You don't have to retrieve the CstNode yourself, you can just override the protected runConverter method, and bind your custom ValueConverter in your services declaration.

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@spoenemann
Comment options

@msujew
Comment options

@drhagen
Comment options

@msujew
Comment options

@drhagen
Comment options

Answer selected by msujew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants