Obtaining the value of a token in LL(*) Parser

SyntaxEditor for WPF Forum

Posted 4 years ago by Antonio Sanchez
Version: 17.2.0662

I an client of Actipro. My company have purchased SyntaxEditor for WPF. I have my own formal language (say 50 BNF production rules). I need to translate it to Lua. I already have Lexer, Grammar and parser. Tree Constructor time. I don't know how to retrieve value of terminals like identifiers or constant numbers.

Can you help me?

Comments (2)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Antonio,

In our C# grammar, we have productions like this:

identifierOrContextualKeyword.Production = @identifier["i"] > AstFrom("i")
	| @contextualKeywordAdd["i"] > AstFrom("i")

And also for numeric AST nodes we do this kind of thing where we set some properties on a LiteralExpression AST node:

primaryExpressionCore.Production = @literalDecimalInteger["l"] > Ast<LiteralExpression>()
  .SetProperty(e => e.Kind, LiteralExpressionKind.DecimalInteger)
  .SetProperty(e => e.StringValue, AstFrom("l"))

I hope those help.

Actipro Software Support

Posted 4 years ago by Antonio Sanchez

Thank you for your answer. It is working for me. I have delayed my answer because I have more than 80  BNF production rules and I wanted to be sure I had no other questions. I am already generating code without problems.

The latest build of this product (v22.1.3) was released 16 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.