Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354918 - Tooltip for grammar rule should depict a list of sample strings matching the resp. rule
Summary: Tooltip for grammar rule should depict a list of sample strings matching the ...
Status: CLOSED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-17 04:50 EDT by Matthias Wienand CLA
Modified: 2011-10-17 16:52 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Wienand CLA 2011-08-17 04:50:46 EDT
Build Identifier: I20110613-1736

While editing a .xtext-file within the Xtext editor, I think that it would be useful to get a list of sample strings which match a given grammar rule. This could be delivered as additional information when moving the mouse over the rule name, or via a selection and a context menu. The list should be generated of as many terms of the grammar rule as possible. So that, if you view a grammar rule as a syntex tree, the process of sample string generation should visit each branch at least once.

Example:
[xtext]
terminal ID: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
Rule: '^'* ID ('.' ID)?;
[/xtext]
[generated list for rule Rule]
a
^ ^Aa . a
^^ _Aa
^^^ ^b_Aa . Aa
^^^^ B0_Aa
^^^^^ ^_b0_Aa . _Aa
^^^^^^ cBb0_Aa
^^^^^^^ ^C_Bb0_Aa . b_Aa
...
[/generated list]

The naive approach I tried to follow to generate this short list switches the quantifiers and alternatives. The maximum number of items quantified by '*' or '+' should be relatively small (~10). 

Maybe it is viable to reuse (parts of) the ANTLR ambiguity calculation to generate the sample strings.

Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-10-17 16:52:19 EDT
I don't think that generated documentation is useful for grammars / terminal rules in any case.