eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[Extensibility] Extending the OCL grammar for QVT and customising error handling #141

Closed eclipse-ocl-bot closed 2 months ago

eclipse-ocl-bot commented 2 months ago

| --- | --- | | Bugzilla Link | 176110 | | Status | CLOSED FIXED | | Importance | P3 enhancement | | Reported | Mar 01, 2007 17:15 EDT | | Modified | May 22, 2013 14:08 EDT | | Version | 1.1.0 | | Reporter | Ed Willink |

Description

I have created a variant of the 1.1M5 org.eclipse.ocl.internal.parser\ package to support extension for e.g. QVTrelation and to support user\ configurable error handling policies such as the use of IMarker. I have\ also fixed a few bugs in the grammar implemntation.

The revised OCL package may be found in

/cvsroot/technology/org.eclipse.gmt/umlx/plugins/org.eclipse.gmt.umlx.eqvtr.cst

The extending QVTr package may be found at

org.eclipse.gmt.umlx.eqvtr.cst.parser in the same plugin.

Brief summaries of the changes and their rationale follows.

The internal.parser refactoring\

No changes: Ascii,g, KWLexerMap.g\

Grammar changes - KeywordTemplateD.g\

Remove unnecessary import.

Grammar changes - OCLKWLexer.g\

Introduce $copyright_contributions, so that...

My QVTrKWLexer.g can import OCLKWLexer.g, define additional keywords and extend the copyright.

Grammar changes - LexerBasicMap.g\

Add an @Override.

Grammar changes - LexerTemplateD.g\

Use AbstractLexer.java base class.\ Add 4 @Overrides.\ Move single argument lexer to AbstractLexer baseclass.

Grammar changes - OCLLexer.g\

Bug fix: remove redundant $\ Bug fix: Remove redundant imports\ Bug fix: Remove duplicate EOF definitions.\ Move error reporting to AbstractLexer base class.\ Introduce setInputChars() to decouple construction and initialisation. Introduce $copyright_contributions, so that...

My QVTrLexer.g can import OCLLexer.g, define additional keywords and extend the copyright.

Grammar changes - OCLLPGParser.g\

Refactor:\ basic error reporting to AbstractLPGParser.java\ OCL creation utilities to AbstractOCLLPGParser.java\ the residual OCL grammar stays in OCLLPGParser.g\ \ My QVTrLPGParser.g just includes .

Bug fix: Correct 'AST'Node type\ Bug fix: Remove redundant imports\ Bug fix: Narrowed operationCallExpCS on unary (MINUS, not) to eliminate reduce/reduce conflicts\ Adjusted createMessageExpCS argument to make baseclass symbol file indepenedent \ Code evolution: Added generic arguments to all Lists.\ Introduce $copyright_contributions

[I put in all the missing generic signatures, but it just moves around the\ unchecked casts with only subjective aesthetic benefits, so I rewound to\ avoid unnecessary differences. Perhaps the next LPG release will support typed\ productions and solve the problem.]

Structure changes - OCLParser.java\

OCLParser used to inherit from OCLLPGParser making it very difficult to independently extend AST and CST layers. It now composes an OCLLPGParser so that there is a consistent structure for each of the four parsers, AST parser composes CST parser composes CST lexer composes KW lexer, and each is extensible.

Refactor:\ basic error reporting/environment to AbstractParser.java\ generic OCL CST to AST conversion to AbstractOCLParser.java\ goal related OCL CST to AST conversion to OCLParser.java

For QVTr, I replace OCLParser by QVTr specific layers.

[The Parser|LPGParser/PrsSteam|Lexer/LexStream|KWLexer naming is not that good. I renamed to ASTParser/CSTParser/CSTLexer/KWLexer which was better then reverted to minimise changes. I think the renaming was a good idea.]\ \ Error handling\

Difficult to configure. I want errors to appear as IMarker elements in a text editor, so introduce ErrorHandler, with ErrorStringHandler for the current behaviour or ... or MarkerErrorHandler for me.

I do not really understand the benefit of a declared SemanticException, it just causes every AST method to have a throws declaration:

Ideally an ErrorHandler would be maintained by Environment so that all errors go via the Environment to the ErrorHandler.

There are nearly five different errors methods for each of lexer, parser and semantic\ analyser. Examination suggests that only one method is used for each, so the\ LexerErrorHandler, ParserErrorHandler and SemanticErrorHandler interfaces have\ just one method each.

I didn't want to edit Environment, so I temporarily support setting ErrorHandler on each abstract parser layer. I'm sure the ErrorHandler interface can be further improved when moved to Environemnt.

Separate queries\

OCL.genmodel\

The Edit and Editor plugin clases are defined as ecore.provider.OCLEditPlugin and ecore.presentation.OCLEditPlugin. Surely an org.eclipse.emf.ocl prefix should be added?

org.eclipse.emf.ocl.edit and org.eclipse.emf.ocl.editor\

These plug-ins may be redundant for pure OCL usage, but they may be needed by OCL extensions.

OCLCST.ecore\

Why isn't composition used throughout? The CST is a simple tree so determination of composition/reference is not hard. Failure to define compositions mean that when the CST is saved to a file, many terms are trivialised to dummies.

internal\

All internal packages report a Java discouraged access.

It would be helpful to adopt the pre-Java 5 policy that 'internal' represents a verbal warning. Since the CST is so useful, the Java warning should be eliminated by exporting the internal packages.

NPEs\

CollectionTypeImpl.getName line 363: elementTypeName = elementType.getName() needs to just skip the elementTypeName if elementType null.

Trivia\

In TypeUtil.matchArgs following the resolution of a Variable arg:

if (argType instanceof EDataType)\
    argType = getOCLTypeFor((EDataType)argType);

is needed in case the source has user domain rather than OCL domain types.