Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "TCS/TCS Toolkit Tutorial"

< TCS
m (added stub remarks)
(documented the obsoleteness of this page)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{Backlink|TCS}}
 
{{Backlink|TCS}}
  
{{stub}}
+
This page documents an obsolete version of TCS. Please, see [[TCS/Language Project]] for the newest version.
  
 
=TCS Tookit Sample Project Tutorial=
 
=TCS Tookit Sample Project Tutorial=
  
This wiki page is a tutorial to help for using the first beta version of the TCS Toolkit available [http://www.eclipse.org/gmt/am3/tcs/download/TCSSample.zip here].
+
This wiki page is a tutorial to help for using the first beta version of the [[TCS]] Toolkit. The TCS Toolkit is available for download [http://www.eclipse.org/gmt/am3/tcs/download/TCSSample.zip here].
 +
 
 +
==Prerequisites==
 +
You should have installed the ATL and AM3 [http://www.eclipse.org/m2m/atl/download/ plugins] and the ant-contrib extension for ant (see [http://wiki.eclipse.org/index.php/AM3_Ant_Tasks documentation]).
  
 
==Content==
 
==Content==
Line 33: Line 36:
 
''This section is under construction. Here are some quick notes.''
 
''This section is under construction. Here are some quick notes.''
  
How to use this Sample Project for my own DSL?
+
===First Step: Setup OK?===
 +
If you have installed all required plugins and imported the example project into Eclipse, try the following steps in the SampleDSL-folder in order to verify that your environment is set up correctly and you get no errors:
 +
 
 +
# Extract the ecore file from the AddressBook.km3. Add temporarily a new attribute (e.g. the line <code>attribute faxNumber: String;</code> to the <code>Contact</code> class), update the Ecore via context menu and ''Inject KM3 to Ecore metamodel'' and check that your new attribute appears in the <tt>AddressBook.ecore</tt> tree editor.
 +
# Right click on <code>TCSSample/SampleDSL/Metamodel/AddressBook.ecore</code> and select ''Register Metamodel''. If you don't do this, the generic Ecore Editor for the Model file <code>sample.adb.ecore</code> will not find the metamodel and reports an error!
 +
# Run the ant scripts SampleDSL_ExtractorCreation.xml and SampleDSL_InjectorCreation.xml. Initially, you have to open the ''Run As > Ant Build...'' dialog and select ''Run in the same JRE as the workspace'' under the JRE tab.
 +
# Test the SampleInjection and SampleExtraction. Run the <code>build.xml</code> as ''Ant Build'' and check that the output file was (re)generated (<code>sample.adb.ecore</code> for Injection, <code>sample.adb.ecore.adb</code> for Extraction). Play around with it, change some entries, regenerate and watch the result.
 +
 
 +
===Second Step: How to use this Sample Project for my own DSL?===
  
 
First, you should create your metamodel by using the KM3 syntax.
 
First, you should create your metamodel by using the KM3 syntax.

Latest revision as of 09:10, 25 June 2008

< To: TCS

This page documents an obsolete version of TCS. Please, see TCS/Language Project for the newest version.

TCS Tookit Sample Project Tutorial

This wiki page is a tutorial to help for using the first beta version of the TCS Toolkit. The TCS Toolkit is available for download here.

Prerequisites

You should have installed the ATL and AM3 plugins and the ant-contrib extension for ant (see documentation).

Content

This section is under construction. Here are some quick notes.

The project "TCSSample" contains two folder:

  • TCSToolkit contains all the required files for using TCS
  • SampleDSL contains a complete example of use case for TCS

Listing of SampleDSL folder:

  • Metamodel/AddressBook.km3: AddressBook metamodel in KM3 syntax
  • Metamodel/AddressBook.ecore: AddressBook metamodel
  • SampleExtraction/build.xml: Ant script for AddressBook extraction (model to text)
  • SampleExtraction/sample.adb.ecore: sample model (to test extraction)
  • SampleInjection/build.xml: Ant script for AddressBook injection (text to model)
  • SampleInjection/sample.adb: sample file using AddressBook grammar (to test injection)
  • TCS/AddressBook.tcs: TCS file for AddressBook
  • TCS/AddressBook-importer.jar: AddressBook injector
  • TCS/AddressBook.tcs.ecore: AddressBook extractor
  • SampleDSL_ExtractorCreation.xml: Ant script to create AddressBook extractor
  • SampleDSL_InjectorCreation.xml: Ant script to create AddressBook injector

Tutorial

This section is under construction. Here are some quick notes.

First Step: Setup OK?

If you have installed all required plugins and imported the example project into Eclipse, try the following steps in the SampleDSL-folder in order to verify that your environment is set up correctly and you get no errors:

  1. Extract the ecore file from the AddressBook.km3. Add temporarily a new attribute (e.g. the line attribute faxNumber: String; to the Contact class), update the Ecore via context menu and Inject KM3 to Ecore metamodel and check that your new attribute appears in the AddressBook.ecore tree editor.
  2. Right click on TCSSample/SampleDSL/Metamodel/AddressBook.ecore and select Register Metamodel. If you don't do this, the generic Ecore Editor for the Model file sample.adb.ecore will not find the metamodel and reports an error!
  3. Run the ant scripts SampleDSL_ExtractorCreation.xml and SampleDSL_InjectorCreation.xml. Initially, you have to open the Run As > Ant Build... dialog and select Run in the same JRE as the workspace under the JRE tab.
  4. Test the SampleInjection and SampleExtraction. Run the build.xml as Ant Build and check that the output file was (re)generated (sample.adb.ecore for Injection, sample.adb.ecore.adb for Extraction). Play around with it, change some entries, regenerate and watch the result.

Second Step: How to use this Sample Project for my own DSL?

First, you should create your metamodel by using the KM3 syntax. Next, you should generate the corresponding Ecore metamodel with the KM3 action "Inject KM3 to Ecore metamodel" available in the context menu. Then, you can create the textual concrete syntax (the tcs file) for your DSL.

Now, you are ready to generate the injector and the extractor for your DSL by using the generic Ant scripts available.

Back to the top