Eclipse Xtext Debuging

Debugging While Contstructing Grammar

This page gives some typical errors.

Constraint is INVALID for Context

Xtext can't resolve same rule with different references. For example 'right_Atom' appears twice in the following rule, once with 'right2=' and once without.

Jright_Atom hidden(WS,KW_NEWLINE):

	(Jleft_Atom (right2=Jright_Atom)?)
	| 'not' right_Atom

To fix the bug apply 'right2=' to the second instance.

Jright_Atom hidden(WS,KW_NEWLINE):

	(Jleft_Atom (right2=Jright_Atom)?)
	| 'not' right2=Jright_Atom

Decision can match input ... using multiple alternatives


warning(200): ../com.euclideanspace.aldor/src-gen/com/euclideanspace/aldor/parser/antlr/internal/InternalEditor.g:4118:1: Decision can match input such as "'not'" using multiple alternatives: 1, 2, 3, 4, 5
As a result, alternative(s) 2,3,4,5 were disabled for that input

This indicates an ambiguous grammar. Syntactic predicates help us to resolve ambiguous grammars as discusses on the page here.

A class may not be a super type of itself.

A recursion loop where there is no instantiation.

All the classes will have an error so it should be possible to determine the loop.

Recursive Rule Invocations

rule rule... has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.

Could not even do k=1 for decision x

see this blog:

try adding:

    		// The antlr parser generator fragment.
    		fragment = parser.antlr.XtextAntlrGeneratorFragment {
    			antlrParam = "-Xconversiontimeout" antlrParam = "10000"
    		// generates a more lightweight Antlr parser and lexer tailored for content assist
    		fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {
    			antlrParam = "-Xconversiontimeout" antlrParam = "10000"

To Generate????.mwe2 file.

Runtime Debugging

Xtext 2.3 now supports debugging of DSLs if you generate Java code from your language. It uses Java's Debugging Support for Other Languages (JSR-045) to allow to set breakpoints in your language and step through the implementation. All you need to do is to provide the mapping information between your DSL files and the generated Java code. This will happen automatically if you use the Xbase infrastructure for your language implementation.

See this page.

metadata block
see also:
  • xtext tools - Useful for looking at node and semantic models
Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2022 Martin John Baker - All rights reserved - privacy policy.