SemanticApplicationDesignLanguage / sadl

Semantic Application Design Language (SADL) Open Source Code
http://semanticapplicationdesignlanguage.github.io/sadl/
Eclipse Public License 1.0
30 stars 12 forks source link

Need help adjusting scoping for new grammar constructs #344

Closed crapo closed 5 years ago

crapo commented 5 years ago

I have extended the EquationStatement grammar to 1) have a "where" clause in which variables can be defined and in which assumptions can be stated, and 2) have a "return" statement that allows the values returned by an equation to be explicitly stated. Note that a previous grammar change allows Equations to return multiple values, in which case a list syntax allows specifying to what variables the return values are assigned. Scoping needs to be enhanced to do the following. a) If a variable is defined in the "where" clause and used in the body, the definition is the reference in the "where" clause. b) If a variable is referenced in the body and referenced in the "return" statement, the definition is the reference in the body.

These changes are pushed to branch AWC-ServicesConfig.

Here's an example .sadl file content:

uri "http://sadl.org/MinimalExample.sadl" alias mex.

 External unitResolver(string u, ...) returns string: "http://sadl.org/unitSelector". 
 External derivative(ScientificConcept numerator, ScientificConcept denominator, int n) returns decimal, string: 
    "http://sadl.org/derivative".

 Mass is a type of UnittedQuantity.
 Velocity is a type of UnittedQuantity.
 Momentum is a type of UnittedQuantity.
 Force is a type of UnittedQuantity.
 Time is a type of UnittedQuantity.

 Equation newtons2ndLaw 
    (note "Force is equal to the derivative of momentum with respect to time.") 
    (Mass m, Velocity v) returns Force: 
    a Force f with ^value fv, with unit fu

    return f

    where mv is a Momentum with ^value (^value of m * ^value of v), with unit unitResolver("*", unit of m, unit of v) and
        [fv,fu] = derivative(mv, Time, 1).
kittaakos commented 5 years ago

I have set up the GH-344 branch for the development. It is a branch from the AWC-ServicesConfig branch. The branch base is f4ff6574.

kittaakos commented 5 years ago

@crapo, the example you have provided has compiler errors. I created a new project with SADL (Eclipse) IDE, added a new x.sadl file and copied over the example from above.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://385.fwk789219251:22/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://385.fwk789219251:48/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

!ENTRY org.apache.log4j 4 0 2018-11-27 12:47:54.876
!MESSAGE org.eclipse.xtext.validation.ResourceValidatorImpl  - java.io.FileNotFoundException: /Users/akos.kitta/dev/wss/theia-sadl/runtime-configuration-assert/test_project/ImplicitModel/SadlImplicitModel.sadl (Permission denied)

!STACK 0
org.eclipse.emf.common.util.WrappedException: java.io.FileNotFoundException: /Users/akos.kitta/dev/wss/theia-sadl/runtime-configuration-assert/test_project/ImplicitModel/SadlImplicitModel.sadl (Permission denied)
    at org.eclipse.xtext.util.Files.writeStringIntoFile(Files.java:177)
    at com.ge.research.sadl.processing.ISadlImplicitModelContentProvider.createImplicitModel(ISadlImplicitModelContentProvider.java:165)
    at com.ge.research.sadl.processing.ISadlImplicitModelContentProvider.createImplicitModel(ISadlImplicitModelContentProvider.java:180)
    at com.ge.research.sadl.processing.SadlModelProcessor.createSadlImplicitModel(SadlModelProcessor.java:667)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.checkImplicitSadlModelExistence(JenaBasedSadlModelProcessor.java:11035)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.addImplicitSadlModelImportToJenaModel(JenaBasedSadlModelProcessor.java:1391)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1016)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:91)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1)
    at org.eclipse.xtext.util.concurrent.CancelableUnitOfWork.exec(CancelableUnitOfWork.java:26)
    at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:527)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:499)
    at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:137)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:86)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.io.FileNotFoundException: /Users/akos.kitta/dev/wss/theia-sadl/runtime-configuration-assert/test_project/ImplicitModel/SadlImplicitModel.sadl (Permission denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at com.google.common.io.Files$FileByteSink.openStream(Files.java:245)
    at com.google.common.io.Files$FileByteSink.openStream(Files.java:233)
    at com.google.common.io.ByteSink.write(ByteSink.java:111)
    at com.google.common.io.Files.write(Files.java:415)
    at org.eclipse.xtext.util.Files.writeStringIntoFile(Files.java:175)
    ... 22 more
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.addMarkers(DefaultResourceUIValidatorExtension.java:60)
    at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.updateValidationMarkers(DefaultResourceUIValidatorExtension.java:46)
    at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.processDelta(MarkerUpdaterImpl.java:93)
    at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.updateMarkers(MarkerUpdaterImpl.java:63)
    at org.eclipse.xtext.builder.builderState.AbstractBuilderState.updateMarkers(AbstractBuilderState.java:82)
    at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:283)
    at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:116)
    at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:288)
    at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:268)
    at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:162)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:91)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1)
    at org.eclipse.xtext.util.concurrent.CancelableUnitOfWork.exec(CancelableUnitOfWork.java:26)
    at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:527)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:499)
    at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:137)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:86)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.addMarkers(DefaultResourceUIValidatorExtension.java:60)
    at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.updateValidationMarkers(DefaultResourceUIValidatorExtension.java:46)
    at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.processDelta(MarkerUpdaterImpl.java:93)
    at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.updateMarkers(MarkerUpdaterImpl.java:63)
    at org.eclipse.xtext.builder.builderState.AbstractBuilderState.updateMarkers(AbstractBuilderState.java:82)
    at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:283)
    at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:116)
    at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:288)
    at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:268)
    at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:162)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:91)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1)
    at org.eclipse.xtext.util.concurrent.CancelableUnitOfWork.exec(CancelableUnitOfWork.java:26)
    at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:527)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:499)
    at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:137)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:86)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:91)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1)
    at org.eclipse.xtext.util.concurrent.CancelableUnitOfWork.exec(CancelableUnitOfWork.java:26)
    at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:527)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:499)
    at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:137)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:86)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.addMarkers(DefaultResourceUIValidatorExtension.java:60)
    at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.updateValidationMarkers(DefaultResourceUIValidatorExtension.java:46)
    at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.processDelta(MarkerUpdaterImpl.java:93)
    at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.updateMarkers(MarkerUpdaterImpl.java:63)
    at org.eclipse.xtext.builder.builderState.AbstractBuilderState.updateMarkers(AbstractBuilderState.java:82)
    at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:283)
    at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:116)
    at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:288)
    at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:268)
    at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:162)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:91)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1)
    at org.eclipse.xtext.util.concurrent.CancelableUnitOfWork.exec(CancelableUnitOfWork.java:26)
    at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:527)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:499)
    at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:137)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:86)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.addMarkers(DefaultResourceUIValidatorExtension.java:60)
    at org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.updateValidationMarkers(DefaultResourceUIValidatorExtension.java:46)
    at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.processDelta(MarkerUpdaterImpl.java:93)
    at org.eclipse.xtext.builder.builderState.MarkerUpdaterImpl.updateMarkers(MarkerUpdaterImpl.java:63)
    at org.eclipse.xtext.builder.builderState.AbstractBuilderState.updateMarkers(AbstractBuilderState.java:82)
    at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:283)
    at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:116)
    at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:288)
    at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:268)
    at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:162)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at com.ge.research.sadl.model.gp.Equation.toFullyQualifiedString(Equation.java:256)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.createExternalEquation(JenaBasedSadlModelProcessor.java:2968)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processStatement(JenaBasedSadlModelProcessor.java:2895)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.processModelElement(JenaBasedSadlModelProcessor.java:1194)
    at com.ge.research.sadl.jena.JenaBasedSadlModelProcessor.onValidate(JenaBasedSadlModelProcessor.java:1078)
    at com.ge.research.sadl.validation.ResourceValidator.doValidate(ResourceValidator.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:72)
    at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:90)
    at com.ge.research.sadl.validation.ResourceValidator.lambda$0(ResourceValidator.java:56)
    at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
    at com.ge.research.sadl.validation.ResourceValidator.validate(ResourceValidator.java:58)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:91)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob$1.exec(ValidationJob.java:1)
    at org.eclipse.xtext.util.concurrent.CancelableUnitOfWork.exec(CancelableUnitOfWork.java:26)
    at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:527)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:499)
    at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:137)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.createIssues(ValidationJob.java:86)
    at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
crapo commented 5 years ago

Not sure why it had compile errors. I've pushed all of my changes to AWC-ServicesConfig in case there was something not pushed.

kittaakos commented 5 years ago

Thank you, I am trying it now.

crapo commented 5 years ago

Ah, figured out what's probably the issue. I modified SadlImplicitModel.sadl: uri "http://sadl.org/sadlimplicitmodel" alias sadlimplicitmodel.

impliedProperty is a type of annotation. expandedProperty is a type of annotation. ScientificConcept is a class. UnittedQuantity is a type of ScientificConcept, described by ^value with values of type decimal, described by unit with values of type string. ^Rule is a class. NamedQuery is a class.

Event is a class.

crapo commented 5 years ago

sorry about that!

kittaakos commented 5 years ago

Yes, it works now. 👍 Do you want me to update the com.ge.research.sadl.processing.ISadlImplicitModelContentProvider.Default to reflect your implicit model modifications or you take care of it?

crapo commented 5 years ago

Actually, this modification is unique to this particular project and so should not be in the default. This is an example of why the implicit model is a SADL model that can be edited by the modeler as needed.

kittaakos commented 5 years ago

This is an example of why the implicit model is a SADL model that can be edited by the modeler as needed.

Noted. I will figure out a way how to manifest your example as a test case without modifying the default implicit model content.

crapo commented 5 years ago

The additional implicit model content could just appear in the current model for the test case. I put it in the implicit model so it would be everywhere automatically available. ScientificConcept is a class. UnittedQuantity is a type of ScientificConcept.

kittaakos commented 5 years ago

The additional implicit model content could just appear in the current model for the test case.

Yeah, it makes sense, and it's straightforward; thanks for the hint.

kittaakos commented 5 years ago

@crapo, I have transformed the constraints into a test case. Can you please review whether it complies the requirements? Thank you!

The definitions are in [] and the references are in <>.

// ------ SETUP ------
uri "http://sadl.org/MinimalExample.sadl" alias mex.
ScientificConcept is a class.
sadlimplicitmodel:UnittedQuantity is a type of ScientificConcept.
External unitResolver(string u, ...) returns string: "http://sadl.org/unitSelector".
External derivative(ScientificConcept numerator, ScientificConcept denominator, int n) returns decimal, string: "http://sadl.org/derivative".
Mass is a type of UnittedQuantity.
Velocity is a type of UnittedQuantity.
Momentum is a type of UnittedQuantity.
Force is a type of UnittedQuantity.
Time is a type of UnittedQuantity.
// ------ END OF SETUP ------

Equation newtons2ndLaw
  (note "Force is equal to the derivative of momentum with respect to time.")
  (Mass [m], Velocity [v]) returns Force:
// BODY
  a Force [f] with ^value <fv>, with unit <fu>

// RETURN
  return <f>

// WHERE
  where [mv] is a Momentum
    with ^value (^value of <m> * ^value of <v>),
    with unit unitResolver("*", unit of <m>, unit of <v>)
    and [[fv],[fu]] = derivative(<mv>, Time, 1).
crapo commented 5 years ago

Yes, that is correct.

kittaakos commented 5 years ago

@crapo, I created a PR for this issue. Could you please try it out locally? Thank you!

crapo commented 5 years ago

Here's a slightly different Equation that doesn't quite work correctly. I've tried to bold, but shows up as "**" because it's a code block, the part that isn't right.

Equation newtons2ndLawConstantMass
    (note "net Force on a physical object is equal to the mass of the object times its acceleration for constant mass.")
    (PhysicalObject [o]) returns Force: a Force [f] with ^value <fv>, with unit <fu>
        return <f>
            where [[mdotv], [mdotu]] is derivative(mass of <o>, ^time, 1) and <mdotv> is 0 and
                [acc] is an Acceleration with ^value **<accv>**, with unit **<accu>** and
                [**[accv],[accu]**] = derivative(velocity of <o>, ^time, 1). 
kittaakos commented 5 years ago

What is a PhysicalObject?

Update: and what is Acceleration?

Update2: Are these correct?

PhysicalObject is a type of UnittedQuantity.
Acceleration is a type of UnittedQuantity.
crapo commented 5 years ago

Sorry, the example uses this ontology. ScientificConcepts1.zip

kittaakos commented 5 years ago

@crapo, in your last example, you have used the following:

(PhysicalObject [o]) returns Force: a Force [f] with ^value <fv>, with unit <fu>

Can you please explain where do we use <fv> and <fu>?

I would have expected the following:

(PhysicalObject [o]) returns Force: a Force [f] with ^value <accv>, with unit <accu>

or

(PhysicalObject [o]) returns Force: a Force [f] with ^value [fv], with unit [fu]

but I do not understand how can fv and fu be a reference.

I have transformed your example into the following test. If you mean something else, please help me with a self-contained (Xtend/Java) test-case. Thank you!

// ------ SETUP ------
uri "http://sadl.org/ScientificConcepts1.sadl" alias scicncpts1.
Time is a type of UnittedQuantity.
Length is a type of UnittedQuantity.
Position is a type of UnittedQuantity,
  described by x-coordinate with values of type Length,
  described by y-coordinate with values of type Length,
  described by z-coordinate with values of type Length,
  described by ^time with values of type Time.
Mass is a type of UnittedQuantity.
PhysicalObject is a class,
  described by mass with values of type Mass,
  described by position with values of type Position.
Velocity is a type of UnittedQuantity.
velocity describes PhysicalObject with values of type Velocity.
Acceleration is a type of UnittedQuantity.
acceleration describes PhysicalObject with values of type Acceleration.
Momentum is a type of UnittedQuantity.
momentum describes PhysicalObject with values of type Momentum.
Force is a type of UnittedQuantity.
force describes PhysicalObject with values of type Force.
External unitResolver(string operation, string u, ...) 
  returns string: "http://sadl.org/unitSelector".
External derivative(ScientificConcept numerator, anyURI ^time, int n) 
  returns decimal, string: "http://sadl.org/derivative".
ScientificConcept is a class.
sadlimplicitmodel:UnittedQuantity is a type of ScientificConcept.
// ------ END OF SETUP ------

Equation newtons2ndLawConstantMass
  (note "net Force on a physical object is equal to the mass of the object times its acceleration for constant mass.")
  (PhysicalObject [o]) returns Force: a Force [f] with ^value <accv>, with unit <accu>
    return <f>
      where [[mdotv], [mdotu]] is derivative(mass of <o>, ^time, 1) and <mdotv> is 0 and
        [acc] is an Acceleration with ^value <accv>, with unit <accu> and
        [[accv],[accu]] = derivative(velocity of <o>, ^time, 1).
kittaakos commented 5 years ago

I have created a PR with the fixes: https://github.com/crapo/sadlos2/pull/348

FYI: scoping for the equation statements is broken on the development. The PR should fix it.

GEGlobalResearch commented 5 years ago

Sorry, my example was wrong. It was missing the definition of fv, fu. I will create a Java test case, but won't get to it until Monday. To document, once I fixed the example I get cross linking between two equations (without latest PR):


Equation newtons2ndLaw (note "net Force on a physical object is equal to the derivative of the momentum of the object with respect to time.") (PhysicalObject o) returns Force: a Force f with ^value fv, with unit fu return f where mv is a Momentum with ^value (^value of mass of o ^value of velocity of o), with unit unitResolver("", unit of mass of o, unit of velocity of o) and [fv,fu] = derivative(mv, ^time, 1). Equation newtons2ndLawConstantMass (note "net Force on a physical object is equal to the mass of the object times its acceleration for constant mass.") (PhysicalObject o) returns Force: a Force f with ^value fv, with unit fu return f where acc is an Acceleration with ^value accv, with unit accu and [mdotv, mdotu] is derivative(mass of o, ^time, 1) and mdotv is 0 and [accv,accu] = derivative(velocity of o, ^time, 1) and fv = ^value of mass of o accv and fu = unitResolver("", unit of mass of o, accu).


"fv", "fu" in the second equation are hyperlinked to the definition in the first equation.

crapo commented 5 years ago

I've updated the test case with the corrected equation and also a prior equation where I saw cross-linking of variables with a prior version of the code. Commit is here.

kittaakos commented 5 years ago

@crapo, I have fixed the tests and pushed my changes to your AWC-ServicesConfig branch: https://github.com/crapo/sadlos2/commit/f41940b3bceaa514b896a34df283b58b8d54ca39.

crapo commented 5 years ago

Wow! You were working late :-)

crapo commented 5 years ago

This appears to all work properly now. Excellent!