Hi Wilbert,

to add support for primitive types to a language I'd suggest the 
following procedure:

1. Define a metaclass 'PrimitiveType' as subclass of 'Type'. (Do not add 
metaclasses for concrete primitive types)

2. Create a Java class (or enumeration) with constants for all primitive 
types. These constants should be instances of the PrimitiveType class.

3. Modify the reference resolver for TypedElement.type (should be called 
TypedElementTypeReferenceResolver). Adjust the resolve() method to look 
whether there is a primitive type defined by a constant with the correct 
name. If resolveFuzzy is true, add all primitive types to the mapping to 
enable code completion.

Primitive types are different from other types because they do not need 
to be declared. As such, they should not be part of the syntax definition.

Introducing a special metaclass for type references is on needed if you 
require qualified names as in Java and if you cannot define a token for 
these names. In Java this is not possible, because the dot is also used 
for other things than qualified names (e.g. chained method calls).

Hoping this helps...

Best regards,

Mirko


30.03.2011 13:51, Wilbert Alberts:
> Hi,
> I've created a language that consists of so called primitive types and
> typed variables. My meta model contains the concepts Variable, which is
> a specifialization of a TypedElement. A TypedElement has a reference to
> a Type and a name attribute (EString). The meta model furthermore
> contains a PrimitiveType concept and specialications like IntType and
> FloatType. PrimitiveType is a specialisation of Type.
> In my concrete syntax file, I have the following rules:
> IntType ::= "int"
> Variable ::= name[] ":" type[]
> If I'm right, the type[] now means that the parser accepts a reference
> to a type. When I type a variable declaration like /foo: int/, then a
> parse error is shown indicating that int is not a valid reference to a
> type. This is correct as int /is/ a type in stead of a reference to a type.
> This seems to be a common problem. How is this solved in general? I
> peeked into the java (jamopp) example and it seems a TypeReference
> concept is introduced and IntType is specialized from Type and
> TypeReference. Are there other elegant solutions?
> Greetings,
> Wilbert.
>
> -- The information contained in this communication and any attachments
> is confidential and may be privileged, and is for the sole use of the
> intended recipient(s). Any unauthorized review, use, disclosure or
> distribution is prohibited. Unless explicitly stated otherwise in the
> body of this communication or the attachment thereto (if any), the
> information is provided on an AS-IS basis without any express or implied
> warranties or liabilities. To the extent you are relying on this
> information, you are doing so at your own risk. If you are not the
> intended recipient, please notify the sender immediately by replying to
> this message and destroy all copies of this message and any attachments.
> ASML is neither liable for the proper and complete transmission of the
> information contained in this communication, nor for any delay in its
> receipt.
>
>
>
> _______________________________________________
> emftext-users mailing list
> [email protected]
> http://mail-st.inf.tu-dresden.de/cgi-bin/mailman/listinfo/emftext-users


-- 
Dipl.-Inf. Mirko Seifert
Research Assistant

Technische Universität Dresden
Department of Computer Science

Fax   +49 351 463 38459
Email [email protected]

EMFText - Textual Syntax for Models. http://emftext.org
JaMoPP - Java Model Parser and Printer. http://jamopp.org
_______________________________________________
emftext-users mailing list
[email protected]
http://mail-st.inf.tu-dresden.de/cgi-bin/mailman/listinfo/emftext-users

Reply via email to