Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.doc/doc/036-tutorial-remove-comment_C.textile')
-rw-r--r--plugins/org.eclipse.etrice.doc/doc/036-tutorial-remove-comment_C.textile118
1 files changed, 0 insertions, 118 deletions
diff --git a/plugins/org.eclipse.etrice.doc/doc/036-tutorial-remove-comment_C.textile b/plugins/org.eclipse.etrice.doc/doc/036-tutorial-remove-comment_C.textile
deleted file mode 100644
index 92e65878e..000000000
--- a/plugins/org.eclipse.etrice.doc/doc/036-tutorial-remove-comment_C.textile
+++ /dev/null
@@ -1,118 +0,0 @@
-h1. Tutorial Remove C-Comment ( C )
-
-h2. Scope
-
-In this tutorial you will create a more complex model. The model implements a simple parser that removes comments (block comments and line comments) from a C source file. Therefore we will create two actors. One actor is responsible to perform the file operations, whether the second actor implements the parser.
-
-You will perform the following steps:
-
-# create a new model from scratch for C
-# define a protocol
-# define your own data type
-# create the structure and the behavior by yourself
-# generate, build and run the model
-
-Make sure that you have set up the workspace as described in _Setting up the Workspace for C Projects_.
-
-h2. Create a new model from scratch
-
-Remember the following steps from the previous tutorials:
-- select the _C/C++_ perspective
-- From the main menue select _File->New->C Project_
-- Name the project _RemoveComment_
-- Project type is _Executable / Empty C Project_
-- Toolchain is _MinGW_
-- Add the folder _model_
-- Add the model file and name it _RemoveComment.room_
-- Add the Xtext nature.
-
-The workspace should look like this:
-
-!images/036-RemoveCommentC01.png!
-
-Create a launch configuration for the C generator and add the include path and library as described in _HelloWorldC_.
-
-The workspace should look like this:
-
-!images/036-RemoveCommentC02.png!
-
-Now the model is created and all settings for the code generator, compiler and linker are done.
-
-
-h2. Create your own data type
-
-The planed application should read a C source file and remove the comments. Therefore we need a file descriptor which is not part of the basic C types. The type for the file descriptor for MinGW is _FILE_. To make this type available on the model level, you have to declare the type.
-
-Open the file _Types.room_ from _org.eclipse.modellib.c_ and take a look at the declaration of _string_ (last line) which is not a basic C type.
-
-_PrimitiveType string:ptCharacter -> charPtr default "0"_
-
-With this declaration, you make the _string_ keyword available on model level as a primitive type. This type will be translated to _charPtr_ in your C sources. _charPtr_ is defined in _etDatatypes.h_. This header file is platform specific (_generic_). With this mechanism you can define your own type system on model level and map the model types to specific target/platform types.
-
-To not interfere with other models, we will declare the type direct in the model.
-Add the following line to your model:
-
-bc..
-RoomModel RemoveComment {
- import room.basic.types.* from "../../../org.eclipse.etrice.modellib.c/model/Types.room"
-
- PrimitiveType file:ptInteger -> FILE default "0"
-bq.
-
-_FILE_ is the native type for MinGW. Therefore you donīt need a mapping within _etDatatypes.h_. If your model should be portable across different platforms you should not take this shortcut.
-
-h2. Create the model
-
-Due to the former tutorials you should be familiar with the steps to create the model with protocols, actors and state machines.
-
-The basic idea of the exercise is to create a file reader actor, which is responsible to open, close and read characters from the source file. Another actor receives the characters and filters the comments (parser). The remaining characters (pure source code) should be print out.
-
-Remember the logical steps:
-- create the model by the help of content assist (CTRL Space)
-- name the model, subsystem and top level actor
-- define the protocol (in this case it should be able to send a char, and to request the next char from the file reader)
-- create the structure (file reader and parser with an appropriate port, create the references and connect the ports)
-- create the state machines
-
-Try to create the model by yourself and take the following solution as an example.
-
-Structure:
-
-!images/036-RemoveCommentC04.png!
-
-File reader FSM:
-
-!images/036-RemoveCommentC05.png!
-
-Parser FSM:
-
-!images/036-RemoveCommentC06.png!
-
-The complete model can be found in _org.eclipse.etrice.tutorials.c_
-
-Take a look at the file attribute of the file reader.
-
-bc..
-Attribute f:file ref
-bq.
-
-_fopen_ expects a _FILE *_. _f:file ref_ declares a variable _f_ from type reference to _file_, which is a pointer to _FILE_.
-
-
-h2. Generate, build and run the model
-
-Before you can run the model you should copy one of the generated C source files into the project folder and name it _test.txt_.
-
-!images/036-RemoveCommentC07.png!
-
-Generate, build and run the model.
-
-Your output should start like this:
-
-!images/036-RemoveCommentC08.png!
-
-
-h2. Summary
-
-This tutorial should help you to train the necessary steps to create a C model. By the way you have seen how to create your own type system for a real embedded project. An additional aspect was to show how simple it is to separate different aspects of the required functionality by the use of actors and protocols and make them reusable.
-

Back to the top