Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » An internal error occurred during: "calculating highlighting".(An internal error occurred during: "calculating highlighting". java.lang.NullPointerException in xtext semantic highlighting)
An internal error occurred during: "calculating highlighting". [message #1764893] Sat, 03 June 2017 04:25 Go to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Hi,
I tried to apply semantic highlighting for the following grammar rule.
definition_stream:
	(ann += annotation)* DEFINE STREAM source '(' feature += Features (',' feature += Features )* ')'';'?		 		
;
source:
	inner='#'? (str_id = stream_id)
;
stream_id:
	name
;


I have created a new SiddhiSemanticHighlightingCalculator class extending DefaultSemanticHighlightingCalculator class and put the followng code segment to highlight source name.
INode root = resource.getParseResult().getRootNode();
		
		for(INode node: root.getAsTreeIterable()){
			if(node.getGrammarElement()== siddhiGrammarAccess.getDefinition_streamAccess().getSourceParserRuleCall_3()){
				acceptor.addPosition(node.getOffset(), node.getLength(), SiddhiHighlightingConfiguration.KEYWORD_ID);
			}
			
			//if(node.getGrammarElement()== siddhiGrammarAccess.getDefinition_functionRule())
		}
		super.doProvideHighlightingFor(resource, acceptor, CancelIndicator.NullImpl);


Then added the semantic highlighting class to the ui module as follows.
 public Class <?extends DefaultSemanticHighlightingCalculator> bindSemanticHighlightingCOnfiguration(){
	  return SiddhiSemanticHighlightingCalculator.class;
  }


But unfortunately when editor is opened a popup mesasge box appears and says the above mentioned error "An internal error occurred during: "calculating highlighting". java.lang.NullPointerException in xtext semantic highlighting". I had already done the custom syntax highlighting part and need some advice on this error.

Thank you very much .


Re: An internal error occurred during: "calculating highlighting". [message #1764894 is a reply to message #1764893] Sat, 03 June 2017 04:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
Hi do you have a stackttrace a well

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1764897 is a reply to message #1764894] Sat, 03 June 2017 06:25 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Hi
Actually there's no stacktrace. Only a pop up message comes after opening the editor file of the new language with the above error on the message box.
Re: An internal error occurred during: "calculating highlighting". [message #1764898 is a reply to message #1764897] Sat, 03 June 2017 06:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
no i mean; if you have a look at the error load view. or the log view in the "host" eclipse (where you develop the dsl) there should be something

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1764899 is a reply to message #1764898] Sat, 03 June 2017 07:06 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Hi
Sorry for jumbling up. This is the stack trace.
 [main] ERROR org.eclipse.xtext.ui.editor.model.XtextDocument  - Error in IXtextModelListener
java.lang.NullPointerException
	at org.xtext.example.siddhiql.ui.syntaxhighlight.SiddhiSemanticHighlightingCalculator.provideHighlightingFor(SiddhiSemanticHighlightingCalculator.java:21)
	at org.eclipse.xtext.ide.editor.syntaxcoloring.MergingHighlightedPositionAcceptor.provideHighlightingFor(MergingHighlightedPositionAcceptor.java:63)
	at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.reconcilePositions(HighlightingReconciler.java:151)
	at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler.modelChanged(HighlightingReconciler.java:402)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.notifyModelListeners(XtextDocument.java:215)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:535)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:492)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:133)
	at org.eclipse.xtext.ui.editor.outline.impl.OutlinePage.initializeTreeContent(OutlinePage.java:147)
	at org.eclipse.xtext.ui.editor.outline.impl.OutlinePage.configureTree(OutlinePage.java:128)
	at org.eclipse.xtext.ui.editor.outline.impl.OutlinePage.createControl(OutlinePage.java:99)
	at org.eclipse.ui.views.contentoutline.ContentOutline.doCreatePage(ContentOutline.java:131)
	at org.eclipse.ui.part.PageBookView.createPage(PageBookView.java:400)
	at org.eclipse.ui.part.PageBookView.partActivated(PageBookView.java:743)
	at org.eclipse.ui.part.PageBookView.showBootstrapPart(PageBookView.java:926)
	at org.eclipse.ui.part.PageBookView.createPartControl(PageBookView.java:484)
	at org.eclipse.ui.views.contentoutline.ContentOutline.createPartControl(ContentOutline.java:118)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:150)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityView.createPartControl(CompatibilityView.java:143)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:340)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:966)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:931)
	at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:151)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:375)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:294)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:105)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:56)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:975)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:651)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$1.run(PartRenderingEngine.java:536)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:520)
	at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.createWidget(ElementReferenceRenderer.java:70)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:975)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:651)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1317)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:103)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:669)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:70)
	at org.eclipse.e4.ui.workbench.renderers.swt.SashRenderer.processContents(SashRenderer.java:142)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:665)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:70)
	at org.eclipse.e4.ui.workbench.renderers.swt.SashRenderer.processContents(SashRenderer.java:142)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:665)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:70)
	at org.eclipse.e4.ui.workbench.renderers.swt.SashRenderer.processContents(SashRenderer.java:142)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:665)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:70)
	at org.eclipse.e4.ui.workbench.renderers.swt.SashRenderer.processContents(SashRenderer.java:142)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:665)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:70)
	at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveRenderer.processContents(PerspectiveRenderer.java:49)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:665)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:82)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:103)
	at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.postProcess(PerspectiveStackRenderer.java:63)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:669)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:70)
	at org.eclipse.e4.ui.workbench.renderers.swt.SashRenderer.processContents(SashRenderer.java:142)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:665)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:70)
	at org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer.processContents(WBWRenderer.java:725)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:665)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1059)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1492)


Thank you.
Re: An internal error occurred during: "calculating highlighting". [message #1764900 is a reply to message #1764899] Sat, 03 June 2017 07:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
That line is in yourcode

Use the debugger to find out which element is null

The parse result? The grammar access ? ...


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1764987 is a reply to message #1764900] Mon, 05 June 2017 14:43 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Hi,
Sorry for late replies since I had some university work.
node.getGrammarElement() is not null.
siddhiGrammarAccess.getDefinition_streamAccess().getSourceParserRuleCall_3() goes to catch block with null pointer exception in notifyModelListeners() method XtextDocument class.

Thank you.

[Updated on: Mon, 05 June 2017 14:47]

Report message to a moderator

Re: An internal error occurred during: "calculating highlighting". [message #1765000 is a reply to message #1764987] Mon, 05 June 2017 16:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
Can you post the exact code with the npe

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1765002 is a reply to message #1765000] Mon, 05 June 2017 16:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
(siddhiGrammarAccess.getDefinition_streamAccess().getSourceParserRuleCall_3()) is generated code

is siddhiGrammarAccess null? or something along the chain? getDefinition_streamAccess getSourceParserRuleCall_3?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1765003 is a reply to message #1765000] Mon, 05 June 2017 16:34 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
siddhiGrammarAccess.getDefinition_streamAccess() is the place where npe occurs and stops debugging.
Re: An internal error occurred during: "calculating highlighting". [message #1765004 is a reply to message #1765003] Mon, 05 June 2017 16:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
are you sure you did not miss the @Inject on siddhiGrammarAccess?

ususally the code for the getDefinition_streamAccess() looks like similar to

	public GreetingElements getGreetingAccess() {
		return pGreeting;
	}


=> if the loading of the grammar works fine there should be no npe


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1765011 is a reply to message #1765004] Mon, 05 June 2017 16:55 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Hi
I am so sorry, somehow I have missed the annotation. Thank you very much :) :)
Re: An internal error occurred during: "calculating highlighting". [message #1765053 is a reply to message #1765011] Tue, 06 June 2017 08:42 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Hi

The Antlr grammar rule for double is as follows.
DOUBLE_LITERAL
    : DIGIT+ ( '.' DIGIT* )? ( E [-+]? DIGIT+ )? D
;
fragment DIGIT : [0-9];


The converted Xtext grammar rule is :
DOUBLE_LITERAL:
	DIGIT+ ( '.' DIGIT* )?  ( E ('-'|'+')? DIGIT+ )? D
;
fragment DIGIT:
	INT
;
@Override 
terminal INT returns ecore::EInt: 
    ('0'..'9');


Is this conversion correct?
The double values inserted in the following query in the editor seems errornous.
from purchase[price >= 30]#window.lossyFrequent(0.1,0.01) --double
select cardNo, price 
insert into PotentialFraud ;


Thank you.

[Updated on: Tue, 06 June 2017 08:43]

Report message to a moderator

Re: An internal error occurred during: "calculating highlighting". [message #1765077 is a reply to message #1765053] Tue, 06 June 2017 12:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
what do you mean by "errornous"

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1765103 is a reply to message #1765077] Tue, 06 June 2017 15:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
p.S: and what is the "D" thingy wouldnt that need "0.01d" ????

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1765163 is a reply to message #1765103] Wed, 07 June 2017 07:45 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Hi,
Sorry the whole grammar rule is:
DOUBLE_LITERAL:
	DIGIT+ ( '.' DIGIT* )?  ( E ('-'|'+')? DIGIT+ )? D
	|DIGIT+ ( '.' DIGIT* )?   E ('-'|'+')? DIGIT+  D?
	|(DIGIT+)? '.' DIGIT+ ( E ('-'|'+')? DIGIT+ )? D
;


Thank you.
Re: An internal error occurred during: "calculating highlighting". [message #1765164 is a reply to message #1765163] Wed, 07 June 2017 07:52 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
In the following query when I replace 0.1,0.01 with integers the error disappears.
from purchase[price >= 30]#window.lossyFrequent(0.1,0.01) --double
select cardNo, price 
insert into PotentialFraud ;

Re: An internal error occurred during: "calculating highlighting". [message #1765165 is a reply to message #1765164] Wed, 07 June 2017 07:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
sorry: create new Grammar With

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Model:
	greetings+=Greeting*;
	
Greeting:
	'Hello' name=ID value=DOUBLE_LITERAL '!';

DOUBLE_LITERAL:
	DIGIT+ ( '.' DIGIT* )?  ( E ('-'|'+')? DIGIT+ )? D
	|DIGIT+ ( '.' DIGIT* )?   E ('-'|'+')? DIGIT+  D?
	|(DIGIT+)? '.' DIGIT+ ( E ('-'|'+')? DIGIT+ )? D
;

E: "e"|"E";
D: "D"|"d";
fragment DIGIT:
	INT
;
@Override 
terminal INT returns ecore::EInt: 
    ('0'..'9');


and youll get tons of warnings


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1765239 is a reply to message #1765165] Wed, 07 June 2017 18:39 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Yes, warnings came. Actually why those warnings are coming? Is it due to ambiguity in the rule? Some how the following worked.
from purchase[price >= 30]#window.lossyFrequent(0.1d,0.01d) 
select cardNo, price 
insert into PotentialFraud ;


In the following query x and y after select seems a wrong input since they are single characters. Once I change them to xa and yb no error appears in the editor.
from PolarStream # pol2Cart(theta, rho) 
select x, y -- string terminal
insert into outputStream ;


Thank you.
Re: An internal error occurred during: "calculating highlighting". [message #1765241 is a reply to message #1765239] Wed, 07 June 2017 18:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
Do you have a spec / unit tests of what you want to parse.

maybe

DOUBLE_LITERAL hidden():
// DIGIT+ ( '.' DIGIT* )? ( E ('-'|'+')? DIGIT+ )? D
DIGIT+ ( '.' DIGIT* )? ((E ('-'|'+')? DIGIT+ D?) | D)
| '.' DIGIT+ ( E ('-'|'+')? DIGIT+ )? D
;

is what you want, maybe not ...


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Wed, 07 June 2017 19:12]

Report message to a moderator

Re: An internal error occurred during: "calculating highlighting". [message #1765277 is a reply to message #1765241] Thu, 08 June 2017 05:15 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
The original Anltr rule is :
DOUBLE_LITERAL
    : DIGIT+ ( '.' DIGIT* )? ( E [-+]? DIGIT+ )? D
    | DIGIT+ ( '.' DIGIT* )?  E [-+]? DIGIT+  D?
    | (DIGIT+)? '.' DIGIT+ ( E [-+]? DIGIT+ )? D?
    ; 


Left factoring cannot be done according to this rule I guess. Thank you.
Re: An internal error occurred during: "calculating highlighting". [message #1765280 is a reply to message #1765277] Thu, 08 June 2017 06:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
no i mean by what it should do ?!?

when is a d required when not?

DIGIT . DIGIT E DIGIT D can be parsed by the first and the second part and the third cant it?
if the third part start with digit it will be parsed by the first one anyway

regarding your x and y. please isolate the problem in a hello world grammar. dont know what you do there and your grammar is too big

=> when is the D required and when not?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1765284 is a reply to message #1765280] Thu, 08 June 2017 07:15 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
After overriding ID terminal x,y error disappears.
Re: An internal error occurred during: "calculating highlighting". [message #1765288 is a reply to message #1765284] Thu, 08 June 2017 07:44 Go to previous messageGo to next message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Hi

Can I create a fragment rule for the following Antlr fragment?
SCRIPT
 : '{' SCRIPT_ATOM* '}'
 ;

 fragment SCRIPT_ATOM
  : ~[{}]
  | '"' ~["]* '"'
  | '//' ~[\r\n]*
  | SCRIPT
  ;


I could create a terminal rule as follows.
SCRIPT:
	'{' SCRIPT_ATOM* '}'
;

terminal SCRIPT_ATOM:
  ! ('{' | '}')
  | '"' (!'"')* '"'
  | '//' !('\r'|'\n')*
  //| SCRIPT
;


But SCRIPT parser rule cannot be called inside the terminal rule. What needs to be done here?
Thank you.
Re: An internal error occurred during: "calculating highlighting". [message #1765290 is a reply to message #1765288] Thu, 08 June 2017 08:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
can you please open a new topic for a new problem

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: An internal error occurred during: "calculating highlighting". [message #1765291 is a reply to message #1765290] Thu, 08 June 2017 08:02 Go to previous message
Udeshika Sewwandi is currently offline Udeshika SewwandiFriend
Messages: 118
Registered: March 2017
Senior Member
Ok . I am sorry :)
Previous Topic:manage eopposite references coming from imported metamodel
Next Topic:Converting fragment from Antlr to Xtext
Goto Forum:
  


Current Time: Fri Dec 06 08:03:59 GMT 2024

Powered by FUDForum. Page generated in 0.06386 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top