|
From: <ma...@us...> - 2009-05-02 14:22:25
|
Revision: 240
http://scstudio.svn.sourceforge.net/scstudio/?rev=240&view=rev
Author: madzin
Date: 2009-05-02 13:42:24 +0000 (Sat, 02 May 2009)
Log Message:
-----------
add new functionality: many msc in one file, recognize first line from Visio file ('mscdocument'), error reports
fix bugs: many coregions on one instance
Modified Paths:
--------------
trunk/src/data/Z120/CMakeLists.txt
trunk/src/data/Z120/Context.cpp
trunk/src/data/Z120/Context.h
trunk/src/data/Z120/Z120.g
trunk/src/data/Z120/main.cpp
trunk/src/data/Z120/z120.h
trunk/src/data/Z120/z120_load.cpp
trunk/tests/z120_test.cpp
Modified: trunk/src/data/Z120/CMakeLists.txt
===================================================================
--- trunk/src/data/Z120/CMakeLists.txt 2009-05-01 13:25:31 UTC (rev 239)
+++ trunk/src/data/Z120/CMakeLists.txt 2009-05-02 13:42:24 UTC (rev 240)
@@ -28,6 +28,7 @@
# Petr: to be removed after proper integration
TARGET_LINK_LIBRARIES(parser
scmsc
+ scZ120
${PARSER_LIBRARIES})
ENDIF(ANTLR_FOUND)
Modified: trunk/src/data/Z120/Context.cpp
===================================================================
--- trunk/src/data/Z120/Context.cpp 2009-05-01 13:25:31 UTC (rev 239)
+++ trunk/src/data/Z120/Context.cpp 2009-05-02 13:42:24 UTC (rev 240)
@@ -32,6 +32,7 @@
#include <list>
#include <set>
#include "data/msc.h"
+#include "z120.h"
struct Context
{
@@ -44,15 +45,23 @@
std::string element_name;
/*
+ * Textual file
+ */
+ std::map<std::string, MscPtr> mscs; //map of msc in the file
+ std::set<std::string> nonpointed; //msc which is not refered
+ std::map<std::string, std::set<ReferenceNodePtr> > future_reference; //map of name of nodes on which was refered and does not exist
+ Z120* z;
+
+ /*
* BMsc
*/
BMscPtr myBmsc;
std::set<std::string> coregion_area_finished; // set of instances which has currently finished coregion area
+ std::set<std::string> coregion_area_opened; //set of instances which has currently opend coregion area
std::map<std::string, InstancePtr> instances; // map of instances (key: name of instance, value: smart pointer to instance)
- std::map<std::string, CompleteMessagePtr> messages; // map of complete messages
-// std::map<std::string, EventPtr> coregion_events; // map of events in coregions
+ std::multimap<std::string, CompleteMessagePtr> messages; // map of future complete messages
std::map<std::string, EventPtr> future_events; // map of name of events on which was pointed before they were created
- std::map<std::string, CoregionEvent*> named_events; // map of name of events
+ std::map<std::string, CoregionEventPtr> named_events; // map of name of events
std::set<std::string> order_events; //set of name of events which takes place after keywords 'before', 'after'
EventPtr current_event; //event which was currently created
std::string event_name; //name of event
@@ -61,9 +70,11 @@
* HMsc
*/
HMscPtr myHmsc;
+ StartNodePtr start_node;
std::pair<std::string, EndNodePtr> end_node;
- std::list<std::string> connect_name; // name of HMsc nodes to which node is connected
+ std::list<std::string> connect_name; // name of HMsc nodes which are successors of actual node
std::string reference_name;
+ std::string condition_name;
std::map<std::string, HMscNodePtr> hmsc_nodes; // map of hmsc nodes (key: name of node, value: smart pointer to node)
std::map<std::string, std::set<std::string> > future_connections; // map of nodes to which node will be connected
int node_type; //flag to recognize HMsc nodes (ConnectionNode, ReferenceNode, ConditionNode). Used in Z120.g
@@ -84,30 +95,74 @@
*/
void init(struct Context* context)
{
+ context->myBmsc = new BMsc("");
+ context->myHmsc = new HMsc("");
context->myBmsc = NULL;
context->myHmsc = NULL;
context->element_name = "";
context->reference_name = "";
+ context->condition_name = "";
context->node_type = 0;
context->event_name = "";
+ context->coregion_area_finished.clear();
+ context->instances.clear();
+ context->messages.clear();
+ context->future_events.clear();
+ context->named_events.clear();
+ context->current_event = NULL;
+
+ context->start_node = NULL;
+ context->end_node = std::make_pair("", context->end_node.second); //replaice context->end_node.second with NULL
+ context->connect_name.clear();
+ context->hmsc_nodes.clear();
+ context->future_connections.clear();
}
/*
* Return Msc structure.
*/
-struct s_Msc* get_msc_fun(struct Context* context)
+MscPtr get_msc_fun(struct Context* context)
{
- Msc* my_msc;
if (context->myBmsc == NULL)
{
- my_msc = context->myHmsc.get();
+ return context->myHmsc;
}
else
{
- my_msc = context->myBmsc.get();
+ return context->myBmsc;
}
- intrusive_ptr_add_ref(my_msc);
+ return NULL;
+}
+
+struct s_Msc* get_total_msc_fun(struct Context* context)
+{
+ Msc* my_msc = NULL;
+ if(context->nonpointed.size() == 1){
+ if(context->mscs.find(*(context->nonpointed.begin())) == context->mscs.end())
+ {
+ context->z->print_report(RS_ERROR, "Internal Error 01: MSC was not found \n");
+ }
+ else{
+ my_msc = context->mscs.find(*(context->nonpointed.begin()))->second.get();
+ }
+ }
+ else
+ {
+ if(context->nonpointed.size() > 1)
+ {
+ context->z->print_report(RS_ERROR, "Error 02: There are more unreferenced MSC\n");
+ }
+ else
+ {
+ context->z->print_report(RS_ERROR, "Error 03: There is no MSC without reference \n");
+ }
+ }
+
+ if(my_msc != NULL)
+ {
+ intrusive_ptr_add_ref(my_msc);
+ }
return static_cast<s_Msc*> (my_msc);
}
@@ -117,12 +172,14 @@
struct Context* new_context()
{
Context* context = new Context;
- context->myBmsc = new BMsc("");
- context->myHmsc = new HMsc("");
- init(context);
return context;
}
+void add_z_fun(struct Context* context, struct s_Z120* z)
+{
+ context->z = static_cast<Z120*> (z);
+}
+
/*
* Free memory space
*/
@@ -131,21 +188,64 @@
delete context;
}
-// nothing importatn only for my check
+/*
+ * Check if all collections are empty
+ */
+void check_collections_fun(struct Context* context)
+{
+ if(!context->coregion_area_opened.empty())
+ context->z->print_report(RS_ERROR, stringize() << "Warning 04: Instance " << context->element_name << "does not have finished some coregion\n");
-void print(struct Context* context)
+ if(!context->messages.empty())
+ context->z->print_report(RS_ERROR, "Error 05: There is complete message without receiver\n");
+
+ if(!context->future_events.empty())
+ context->z->print_report(RS_ERROR, "Error 06: There is dependency on nonexisted event\n");
+
+ if(!context->order_events.empty())
+ context->z->print_report(RS_ERROR, "Error 07: There is reference to nonexisted event\n");
+
+ if(!context->future_connections.empty())
+ context->z->print_report(RS_ERROR, "Error 08: There is reference to nonexisted node\n");
+}
+
+void check_references_fun(struct Context* context)
{
- if (context->myBmsc == NULL)
+ if(!context->future_reference.empty())
+ context->z->print_report(RS_ERROR, "Error 09: There is references to nonexisted MSC\n");
+}
+
+void msc_was_read_fun(struct Context* context)
+{
+ context->mscs.insert(std::make_pair(context->msc_name, get_msc_fun(context)));
+
+ std::map<std::string, std::set<ReferenceNodePtr> >::iterator future_ref_it;
+ future_ref_it = context->future_reference.find(context->msc_name);
+
+ if(future_ref_it == context->future_reference.end())
{
- std::cout << "node's number " << context->myHmsc->get_nodes().size() << std::endl;
+ context->nonpointed.insert(context->msc_name);
}
else
{
- std::cout << "instance's number " << context->myBmsc->get_instances().size() << std::endl;
+ MscPtr msc = get_msc_fun(context);
+ std::set<ReferenceNodePtr>::iterator references = future_ref_it->second.begin();
+ for(; references != future_ref_it->second.end(); ++references)
+ {
+ (*references)->set_msc(msc);
+ }
+ context->future_reference.erase(future_ref_it);
}
}
/*
+ * Bug report from grammar
+ */
+void bug_report(struct Context* context, char* report){
+ context->z->print_report(RS_ERROR, report);
+}
+
+/*
* Create new BMsc structure
*/
void new_bmsc_fun(struct Context* context)
@@ -159,18 +259,25 @@
void incomplete_message_output_fun(struct Context* context, char* msg_identifications)
{
std::string msg_identification(msg_identifications);
+ std::string msg_name;
size_t pos = msg_identification.rfind(',');
if(pos != 0)
{
- msg_identification = msg_identification.substr(0, pos);
+ msg_name = msg_identification.substr(0, pos);
}
+ else
+ {
+ msg_name = msg_identification;
+ }
InstancePtr instance = context->instances.find(context->element_name)->second;
- if (instance->get_last() == NULL)
+ if (instance->get_last() == NULL ||
+ context->coregion_area_finished.find(context->element_name) != context->coregion_area_finished.end())
{
StrictOrderAreaPtr strict(new StrictOrderArea());
instance->add_area(strict);
+ context->coregion_area_finished.erase(context->element_name);
}
std::map<std::string, EventPtr>::iterator event_it;
@@ -185,19 +292,20 @@
else
{
event = event_it->second;
+ context->future_events.erase(event_it);
}
context->current_event = event;
- IncompleteMessagePtr message = new IncompleteMessage(LOST, msg_identification);
+ IncompleteMessagePtr message = new IncompleteMessage(LOST, msg_name);
message->glue_event(event);
//if event is named, it adds event to named_events
if(context->event_name != "")
{
- CoregionEvent* event1 = dynamic_cast<CoregionEvent*> (event.get());
+ CoregionEventPtr event1 = boost::dynamic_pointer_cast<CoregionEvent>(event);
if(event1 != NULL){
- context->named_events.insert(std::make_pair(context->event_name, event1));
+// context->named_events.insert(std::make_pair(context->event_name, event1));
}
}
@@ -210,18 +318,25 @@
void incomplete_message_input_fun(struct Context* context, char* msg_identifications)
{
std::string msg_identification(msg_identifications);
+ std::string msg_name;
size_t pos = msg_identification.rfind(',');
if(pos != 0)
{
- msg_identification = msg_identification.substr(0, pos);
+ msg_name = msg_identification.substr(0, pos);
}
+ else
+ {
+ msg_name = msg_identification;
+ }
InstancePtr instance = context->instances.find(context->element_name)->second;
- if (instance->get_last() == NULL)
+ if (instance->get_last() == NULL ||
+ context->coregion_area_finished.find(context->element_name) != context->coregion_area_finished.end())
{
StrictOrderAreaPtr strict(new StrictOrderArea());
instance->add_area(strict);
+ context->coregion_area_finished.erase(context->element_name);
}
std::map<std::string, EventPtr>::iterator event_it;
@@ -236,17 +351,18 @@
else
{
event = event_it->second;
+ context->future_events.erase(event_it);
}
context->current_event = event;
- IncompleteMessagePtr message = new IncompleteMessage(FOUND, msg_identification);
+ IncompleteMessagePtr message = new IncompleteMessage(FOUND, msg_name);
message->glue_event(event);
//if event is named, it adds event to named_events
if(context->event_name != "")
{
- CoregionEvent* event1 = dynamic_cast<CoregionEvent*> (event.get());
+ CoregionEventPtr event1 = boost::dynamic_pointer_cast<CoregionEvent>(event);
if(event1 != NULL){
context->named_events.insert(std::make_pair(context->event_name, event1));
}
@@ -277,9 +393,23 @@
*/
void start_coregion_fun(struct Context* context)
{
- InstancePtr instance = context->instances.find(context->element_name)->second;
- CoregionAreaPtr coregion(new CoregionArea());
- instance->add_area(coregion);
+ std::set<std::string>::iterator it = context->coregion_area_finished.find(context->element_name);
+ if(it != context->coregion_area_finished.end())
+ {
+ context->coregion_area_finished.erase(it);
+ }
+
+ if(context->coregion_area_opened.find(context->element_name) == context->coregion_area_opened.end())
+ {
+ InstancePtr instance = context->instances.find(context->element_name)->second;
+ CoregionAreaPtr coregion(new CoregionArea());
+ instance->add_area(coregion);
+ context->coregion_area_opened.insert(context->element_name);
+ }
+ else
+ {
+ context->z->print_report(RS_ERROR, stringize() << "Error 10: Instance " << context->element_name << " has already had opened some coregion\n");
+ }
}
/*
@@ -287,8 +417,16 @@
*/
void end_coregion_fun(struct Context* context)
{
- InstancePtr instance = context->instances.find(context->element_name)->second;
- context->coregion_area_finished.insert(context->element_name);
+ if(context->coregion_area_opened.find(context->element_name) != context->coregion_area_opened.end())
+ {
+ InstancePtr instance = context->instances.find(context->element_name)->second;
+ context->coregion_area_finished.insert(context->element_name);
+ context->coregion_area_opened.erase(context->element_name);
+ }
+ else
+ {
+ context->z->print_report(RS_ERROR, stringize() << "Error 11: Instance " << context->element_name << " does not have opened any coregion\n"); //check
+ }
}
/*
@@ -296,15 +434,22 @@
*/
void message_output_fun(struct Context* context, char* msg_identifications)
{
+ //message identification
std::string msg_identification(msg_identifications);
+ std::string msg_name;
size_t pos = msg_identification.rfind(',');
if(pos != 0)
{
- msg_identification = msg_identification.substr(0, pos);
+ msg_name = msg_identification.substr(0, pos);
}
+ else
+ {
+ msg_name = msg_identification;
+ }
InstancePtr instance = context->instances.find(context->element_name)->second;
-
+
+ //add new strict area to instance if it is needed
if (instance->get_last() == NULL ||
context->coregion_area_finished.find(context->element_name) != context->coregion_area_finished.end())
{
@@ -325,18 +470,28 @@
else
{
event = event_it->second;
+ context->future_events.erase(event_it);
}
context->current_event = event;
- if (context->messages.find(msg_identification) != context->messages.end())
- {
- context->messages.find(msg_identification)->second->glue_send_event(event);
- context->messages.erase(msg_identification);
+ std::multimap<std::string, CompleteMessagePtr>::iterator message_it;
+ message_it = context->messages.find(msg_identification);
+
+ if (message_it != context->messages.end()
+&& message_it->second->get_send_event() == NULL)
+ {
+ message_it->second->glue_send_event(event);
+ context->messages.erase(message_it);
}
else
{
- CompleteMessagePtr message = new CompleteMessage(msg_identification);
+ if(message_it != context->messages.end())
+ {
+ context->z->print_report(RS_ERROR, "Error 12: Message has already had specified the sender\n"); //warning
+
+ }
+ CompleteMessagePtr message = new CompleteMessage(msg_name);
message->glue_send_event(event);
context->messages.insert(std::make_pair(msg_identification, message));
}
@@ -344,7 +499,7 @@
//if event is named, it adds event to named_events
if(context->event_name != "")
{
- CoregionEvent* event1 = dynamic_cast<CoregionEvent*> (event.get());
+ CoregionEventPtr event1 = boost::dynamic_pointer_cast<CoregionEvent>(event);
if(event1 != NULL){
context->named_events.insert(std::make_pair(context->event_name, event1));
}
@@ -359,11 +514,16 @@
void message_input_fun(struct Context* context, char* msg_identifications)
{
std::string msg_identification(msg_identifications);
+ std::string msg_name;
size_t pos = msg_identification.rfind(',');
if(pos != 0)
{
- msg_identification = msg_identification.substr(0, pos);
+ msg_name = msg_identification.substr(0, pos);
}
+ else
+ {
+ msg_name = msg_identification;
+ }
InstancePtr instance = context->instances.find(context->element_name)->second;
@@ -372,11 +532,12 @@
{
StrictOrderAreaPtr strict(new StrictOrderArea());
instance->add_area(strict);
+ context->coregion_area_finished.erase(context->element_name);
}
std::map<std::string, EventPtr>::iterator event_it;
EventPtr event;
-
+
//if the event was created prematurely
if(context->event_name == "" ||
(event_it = context->future_events.find(context->event_name)) == context->future_events.end())
@@ -386,18 +547,27 @@
else
{
event = event_it->second;
+ context->future_events.erase(event_it);
}
context->current_event = event;
- if (context->messages.find(msg_identification) != context->messages.end())
+ std::multimap<std::string, CompleteMessagePtr>::iterator message_it;
+ message_it = context->messages.find(msg_identification);
+
+ if(message_it != context->messages.end()
+&& message_it->second->get_receive_event() == NULL)
{
- context->messages.find(msg_identification)->second->glue_receive_event(event);
- context->messages.erase(msg_identification);
+ message_it->second->glue_receive_event(event);
+ context->messages.erase(message_it);
}
else
{
- CompleteMessagePtr message = new CompleteMessage(msg_identification);
+ if(message_it != context->messages.end())
+ {
+ std::cout << "get receive event nieje null " <<std::endl;
+ }
+ CompleteMessagePtr message = new CompleteMessage(msg_name);
message->glue_receive_event(event);
context->messages.insert(std::make_pair(msg_identification, message));
}
@@ -405,7 +575,7 @@
//if event is named, it adds event to named_events
if(context->event_name != "")
{
- CoregionEvent* event1 = dynamic_cast<CoregionEvent*> (event.get());
+ CoregionEventPtr event1 = boost::dynamic_pointer_cast<CoregionEvent>(event);
if(event1 != NULL){
context->named_events.insert(std::make_pair(context->event_name, event1));
}
@@ -419,26 +589,26 @@
*/
void add_before_relation_fun(struct Context* context){
std::set<std::string>::iterator it;
- std::map<std::string, CoregionEvent*>::iterator named_event_it;
- CoregionEvent* event = dynamic_cast<CoregionEvent*> (context->current_event.get());
+ std::map<std::string, CoregionEventPtr>::iterator named_event_it;
+ CoregionEventPtr event = boost::dynamic_pointer_cast<CoregionEvent>(context->current_event);
if(event == NULL){
-// bug report
+ context->z->print_report(RS_ERROR, "Internal Error 13: Typecast failed\n");
return;
}
for(it = context->order_events.begin(); it != context->order_events.end(); ++it){
if((named_event_it = context->named_events.find(*it)) != context->named_events.end()){
-// CoregEventRelPtr rel = new CoregionEventRelation(NULL, named_event_it->second);
-// event->add_successor(rel);
- event->add_successor(named_event_it->second);
+ event->add_successor(named_event_it->second.get());
}
else{
- CoregionEventPtr event1 = new CoregionEvent();
- context->future_events.insert(std::make_pair(*it, event1));
-// CoregEventRelPtr rel = new CoregionEventRelation(NULL, event1.get());
-// event->add_successor(rel);
- event->add_successor(event1.get());
+ InstancePtr instance = context->instances.find(context->element_name)->second;
+
+ EventPtr event1 = instance->get_last()->add_event();
+ CoregionEventPtr event2 = boost::dynamic_pointer_cast<CoregionEvent>(event1);
+ context->future_events.insert(std::make_pair(*it, event2));
+ event->add_successor(event2.get());
}
}
+ context->order_events.clear();
}
/*
@@ -446,28 +616,26 @@
*/
void add_after_relation_fun(struct Context* context){
std::set<std::string>::iterator it;
- std::map<std::string, CoregionEvent*>::iterator named_event_it;
- CoregionEvent* event = dynamic_cast<CoregionEvent*> (context->current_event.get());
+ std::map<std::string, CoregionEventPtr>::iterator named_event_it;
+ CoregionEventPtr event = boost::dynamic_pointer_cast<CoregionEvent> (context->current_event);
if(event == NULL){
-// bug report
+ context->z->print_report(RS_ERROR, "Internal Error 13: Typecast failed\n");
return;
}
for(it = context->order_events.begin(); it != context->order_events.end(); ++it){
if((named_event_it = context->named_events.find(*it)) != context->named_events.end()){
-// CoregEventRelPtr rel = new CoregionEventRelation(NULL, named_event_it->second);
-// event->add_predecessor(rel);
-//TODO bol by som najradsej keby sa to fungovalo iba so spodnym riadkom na to je potrebne zmenit msc.h msc.cpp
-// event->add_predecessor(named_event_it->second);
+ named_event_it->second->add_successor(event.get());
}
else{
- CoregionEventPtr event1 = new CoregionEvent();
- context->future_events.insert(std::make_pair(*it, event1));
-// CoregEventRelPtr rel = new CoregionEventRelation(NULL, event1.get());
-// event->add_predecessor(rel);
-//TODO bol by som najradsej keby sa to fungovalo iba so spodnym riadkom na to je potrebne zmenit msc.h msc.cpp
-// event->add_predecessor(event1.get());
+ InstancePtr instance = context->instances.find(context->element_name)->second;
+
+ EventPtr event1 = instance->get_last()->add_event();
+ CoregionEventPtr event2 = boost::dynamic_pointer_cast<CoregionEvent>(event1);
+ context->future_events.insert(std::make_pair(*it, event2));
+ event2->add_successor(event.get());
}
}
+ context->order_events.clear();
}
/*
* Set name of instance
@@ -477,7 +645,7 @@
context->element_name = name;
}
-void add_event_name_fun(struct Context* context, char* name)
+void set_event_name_fun(struct Context* context, char* name)
{
context->event_name = name;
}
@@ -492,8 +660,6 @@
void new_hmsc_fun(struct Context* context)
{
context->myHmsc = new HMsc(context->msc_name);
-
- std::cout << "HMscPtr myHmsc(new Hmsc(" << context->msc_name << "));" << std::endl << std::endl;
}
/*
@@ -501,38 +667,28 @@
*/
void new_start_node_fun(struct Context* context)
{
- if (context->connect_name.size() == 1)
- {
- StartNodePtr node = new StartNode();
- context->myHmsc->set_start(node);
- future_connection_fill_in_fun(context);
- }
- else
- {
- std::cout << "error: new_start_node_fun" << std::endl;
- //bug report
- }
- std::cout << "myHmsc->set_start(new StartNode());" << std::endl;
+ StartNodePtr node = new StartNode();
+ context->myHmsc->set_start(node);
+ context->start_node = node;
+ future_connection_fill_in_fun(context);
}
/*
* Create end node of HMsc
*/
-void new_end_node_fun(struct Context* context, char* name)
+void new_end_node_fun(struct Context* context)
{
if (context->connect_name.size() == 0)
{
EndNodePtr node = new EndNode();
context->myHmsc->add_node(node);
- context->end_node = make_pair(context->element_name, node);
+ context->end_node = std::make_pair(context->element_name, node);
+ create_future_connections_fun(context, node.get());
}
else
{
- std::cout << "error: new_end_node_fun" << std::endl;
- //bug report
+ context->z->print_report(RS_ERROR, "Error 14: There is node which is successor of end node\n");
}
-
- std::cout << "myHmsc->add_node(new EndNode());" << std::endl;
}
/*
@@ -544,6 +700,14 @@
}
/*
+ * Set condition name
+ */
+void set_condition_name_fun(struct Context* context, char* name)
+{
+ context->condition_name = name;
+}
+
+/*
* Set name of node
*/
void set_node_name_fun(struct Context* context, char* name)
@@ -565,20 +729,47 @@
void new_reference_node_fun(struct Context* context)
{
std::map<std::string, HMscNodePtr>::iterator it = context->hmsc_nodes.find(context->element_name);
+ std::map<std::string, MscPtr>::iterator msc_it = context->mscs.find(context->reference_name);
+
if (it == context->hmsc_nodes.end())
{
ReferenceNodePtr node = new ReferenceNode();
- BMscPtr bmsc = new BMsc (context->reference_name);
- node->set_msc(bmsc);
+ std::map<std::string, MscPtr>::iterator msc_it = context->mscs.find(context->reference_name);
+
+ if(msc_it == context->mscs.end())
+ {
+ std::map<std::string, std::set<ReferenceNodePtr> >::iterator ref_it = context->future_reference.find(context->reference_name);
+
+ if(ref_it != context->future_reference.end())
+ {
+ ref_it->second.insert(node);
+ }
+ else
+ {
+ std::set<ReferenceNodePtr> my_set;
+ my_set.insert(node);
+ context->future_reference.insert(std::make_pair(context->reference_name, my_set));
+ }
+ }
+ else
+ {
+ node->set_msc(msc_it->second);
+
+ std::set<std::string>::iterator erase_it = context->nonpointed.find(context->reference_name);
+ if(erase_it != context->nonpointed.end())
+ {
+ context->nonpointed.erase(erase_it);
+ }
+ }
+
context->hmsc_nodes.insert(make_pair(context->element_name, node));
context->myHmsc->add_node(node);
future_connection_fill_in_fun(context);
create_future_connections_fun(context, node.get());
- std::cout << "new_referenceNode()" << std::endl;
}
else
{
- //bug report
+ context->z->print_report(RS_ERROR, stringize() << "Error 15: The node " << context->element_name << " has already been existing\n");
}
}
@@ -596,11 +787,10 @@
context->myHmsc->add_node(node);
future_connection_fill_in_fun(context);
create_future_connections_fun(context, node.get());
- std::cout << "new_connectionNode()" << std::endl;
}
else
{
- //bug report
+ context->z->print_report(RS_ERROR, stringize() << "Error 15: The node " << context->element_name << " has already been existing\n");
}
context->node_type = 0;
}
@@ -614,16 +804,15 @@
if (it == context->hmsc_nodes.end())
{
- ConditionNodePtr node = new ConditionNode();
+ ConditionNodePtr node = new ConditionNode(context->condition_name);
context->hmsc_nodes.insert(std::make_pair(context->element_name, node));
context->myHmsc->add_node(node);
future_connection_fill_in_fun(context);
create_future_connections_fun(context, node.get());
- std::cout << "new_conditionNode()" << std::endl;
}
else
{
- //bug report
+ context->z->print_report(RS_ERROR, stringize() << "Error 15: The node " << context->element_name << " has already been existing\n");
}
context->node_type = 0;
}
@@ -633,13 +822,18 @@
*/
void future_connection_fill_in_fun(struct Context* context)
{
+ if(context->element_name == "")
+ {
+ context->element_name = "start";
+ }
+
while (!context->connect_name.empty())
{
std::map<std::string, std::set<std::string> >::iterator future_it;
std::map<std::string, HMscNodePtr>::iterator hmsc_it;
future_it = context->future_connections.find(context->connect_name.front());
- hmsc_it = context->hmsc_nodes.find(context->connect_name.front());
+ hmsc_it = context->hmsc_nodes.find(context->connect_name.front()); //node which has to be connected to current node
if (hmsc_it == context->hmsc_nodes.end() && context->connect_name.front() != context->end_node.first)
{
@@ -647,7 +841,7 @@
{ //check of record existence in future connections for this node
std::set<std::string> my_set;
my_set.insert(context->element_name);
- context->future_connections.insert(std::make_pair(context->element_name, my_set));
+ context->future_connections.insert(std::make_pair(context->connect_name.front(), my_set));
context->connect_name.pop_front();
}
else
@@ -664,12 +858,14 @@
{
SuccessorNode* succ = dynamic_cast<SuccessorNode*> (hmsc_it->second.get());
node->add_successor(succ);
+ context->connect_name.pop_front();
}
else
{
if (context->connect_name.front() == context->end_node.first)
{
node->add_successor(context->end_node.second.get());
+ context->connect_name.pop_front();
}
}
}
@@ -695,7 +891,14 @@
PredecessorNode* node = dynamic_cast<PredecessorNode*> (hmsc_node_it->second.get());
node->add_successor(succ);
}
+ else
+ {
+ PredecessorNode* node = dynamic_cast<PredecessorNode*> (context->start_node.get());
+ node->add_successor(succ);
+ }
}
+
+ context->future_connections.erase(future_it);
}
}
Modified: trunk/src/data/Z120/Context.h
===================================================================
--- trunk/src/data/Z120/Context.h 2009-05-01 13:25:31 UTC (rev 239)
+++ trunk/src/data/Z120/Context.h 2009-05-02 13:42:24 UTC (rev 240)
@@ -30,19 +30,28 @@
struct Context;
struct s_Msc;
+struct s_Z120;
void set_msc_name_fun(struct Context* context, char* name);
void init(struct Context* context);
-struct s_Msc* get_msc_fun(struct Context* context);
+struct s_Msc* get_total_msc_fun(struct Context* context);
struct Context* new_context();
+void add_z_fun(struct Context* context, struct s_Z120* z);
+
void delete_context(struct Context* context);
-void print(struct Context* context);
+void check_collections_fun(struct Context* context);
+void check_references_fun(struct Context* context);
+
+void msc_was_read_fun(struct Context* context);
+
+void bug_report(struct Context* context, char* report);
+
//BMsc
void new_bmsc_fun(struct Context* context);
@@ -68,7 +77,7 @@
void set_instance_name_fun(struct Context* context, char* name);
-void add_event_name_fun(struct Context* context, char* name);
+void set_event_name_fun(struct Context* context, char* name);
// BMscStruct* get_bmsc();
//HMsc
@@ -76,10 +85,12 @@
void new_start_node_fun(struct Context* context);
-void new_end_node_fun(struct Context* context, char* name);
+void new_end_node_fun(struct Context* context);
void set_reference_name_fun(struct Context* context, char* name);
+void set_condition_name_fun(struct Context* context, char* name);
+
void set_node_name_fun(struct Context* context, char* name);
void add_connect_name_fun(struct Context* context, char* name);
Modified: trunk/src/data/Z120/Z120.g
===================================================================
--- trunk/src/data/Z120/Z120.g 2009-05-01 13:25:31 UTC (rev 239)
+++ trunk/src/data/Z120/Z120.g 2009-05-02 13:42:24 UTC (rev 240)
@@ -11,20 +11,22 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * Copyright (c) 2008 Matus Madzin <go...@ma...>
+ * Copyright (c) 2008 Petr Gotthard <pet...@ce...>, Matus Madzin <go...@ma...>
*
* $Id$
*/
-/*
- * we use ANTRL v3 (ANTLR 3.1.1)
- * see http://www.antlr.org
+/* Note:
+ * This grammar corresponds 1:1 to the grammar described in ITU-T Z.120.
+ * All modifications and non-standard extensions must be properly described.
*/
+
grammar Z120;
-options {
- language=C;
- backtrack=true;
+options
+{
+ language = C;
+ backtrack = true;
}
@header{
@@ -32,25 +34,352 @@
}
@members{
- struct Context* context;
+ struct Context* context;
}
-message_sequence_chart returns [struct s_Msc* myMsc] :
+/*
+ * removed due to: Z120.g:40:1: syntax error: antlr: Z120.g:40:1: unexpected token: tokens
+tokens
+{
+ // imaginary tokens
+ MSC;
+}
+*/
+// ----- Lexical Rules
+
+fragment
+Alphanumeric:
+ Letter
+ | Decimal_Digit
+ | National
+;
+
+fragment
+Letter:
+ 'a'..'z' | 'A'..'Z'
+;
+
+fragment
+Decimal_Digit:
+ '0'..'9'
+;
+
+fragment
+National:
+ '`' | '\\'
+ | Left_Curly_Bracket
+ | Vertical_Line
+ | Right_Curly_Bracket
+ | Overline
+ | Upward_Arrow_Head
+;
+
+fragment
+Left_Square_Bracket:
+ '['
+;
+
+fragment
+Right_Square_Bracket:
+ ']'
+;
+
+fragment
+Left_Curly_Bracket:
+ '{'
+;
+
+fragment
+Vertical_Line:
+ '|'
+;
+
+fragment
+Right_Curly_Bracket:
+ '}'
+;
+
+fragment
+Left_Open:
+ '('
+;
+
+fragment
+Left_Closed:
+ Left_Square_Bracket
+;
+
+fragment
+Right_Open:
+ ')'
+;
+
+fragment
+Right_Closed:
+ Right_Square_Bracket
+;
+
+fragment
+Abs_Time_Mark:
+ '@'
+;
+
+fragment
+Rel_Time_Mark:
+ '&'
+;
+
+fragment
+Overline:
+ '~'
+;
+
+fragment
+Upward_Arrow_Head:
+ '^'
+;
+
+fragment
+Full_Stop:
+ '.'
+;
+
+fragment
+Underline:
+ '_'
+;
+
+fragment
+Left_Angular_Bracket:
+ '<'
+;
+
+fragment
+Right_Angular_Bracket:
+ '>'
+;
+
+fragment
+Character_String:
+ Apostrophe (Alphanumeric
+ | Other_Character
+ | Special
+ | '.' | '_' | ' '
+ | Apostrophe Apostrophe)* Apostrophe
+;
+
+fragment
+Text:
+ (Alphanumeric
+ | Other_Character
+ | Special
+ | '.' | '_' | ' '
+ | Apostrophe)*
+;
+
+fragment
+Apostrophe:
+ '\''
+;
+
+fragment
+Other_Character:
+ '?' | '%' | '+' | '-' | '!' | '/' | '*' | '"' | '='
+;
+
+fragment
+Special:
+ Abs_Time_Mark | Rel_Time_Mark
+ | Left_Open | Right_Open
+ | Left_Closed | Right_Closed
+ | Left_Angular_Bracket | Right_Angular_Bracket
+ | '#' | ',' | ';' | ':'
+;
+
+fragment
+Qualifier_Left:
+ '<<'
+;
+
+fragment
+Qualifier_Right:
+ '>>'
+;
+
+fragment
+Qualifier:
+ Qualifier_Left Text Qualifier_Right
+;
+
+NAME:
+ (Alphanumeric | '_' | '.')+
+;
+
+fragment
+STRING:
+ Pure_Data_String
+;
+
+fragment
+Pure_Data_String:
+ Non_Parenthesis /*(parenthesis)? (Pure_Data_String)?*/
+;
+
+parenthesis:
+ nestable_par | equal_par | non_nestable_par
+;
+
+nestable_par:
+ Par Pure_Data_String Par
+;
+
+fragment
+Non_Parenthesis:
+ (Non_Par_Non_Escape /*|
+ escapechar (escapechar | par)*/)
+;
+
+fragment
+Non_Par_Non_Escape:
+ Character_String
+;
+
+non_nestable_par:
+ Par Text Par
+;
+
+// non-standard: Z.120 doesn't specify whitespaces
+WHITESPACE:
+ ('\t' | ' ' | '\r' | '\n')+ { $channel = HIDDEN; }
+;
+
+
+// ----- Comment
+
+end:
+ (comment)? ';'
+;
+
+comment:
+ 'comment' Character_String
+;
+
+text_definition:
+ 'text' Character_String end
+;
+
+
+// ----- Message Sequence Chart Document
+
+// non-standard: Z.120 doesn't define top-level nonterminal
+textual_msc_file [struct s_Z120* my_z120] returns [struct s_Msc* my_msc]:
{
- context = new_context();
+ context = new_context();
+ if(my_z120 != NULL)
+ {
+ add_z_fun(context, $my_z120);
+ }
}
- 'msc' msc_head (msc | hmsc) 'endmsc' end
- {
- $myMsc = get_msc_fun(context);
- print(context);
- delete_context(context);
- }
+ (('mscdocument' instance_kind end)? (message_sequence_chart)*)
+ {
+ check_references_fun(context);
+ $my_msc = get_total_msc_fun(context);
+ delete_context(context);
+ }
+// -> MSC
;
+textual_msc_document:
+ document_head
+ textual_defining_part textual_utility_part
+;
+
+document_head:
+ 'mscdocument' instance_kind ('related' 'to' sdl_reference)?
+ (inheritance)? end
+ (parenthesis_declaration)?
+ data_definition
+ using_clause
+ containing_clause
+ message_decl_clause
+ timer_decl_clause
+;
+
+textual_defining_part:
+ (defining_msc_reference)*
+;
+
+textual_utility_part:
+ 'utilities' (containing_clause)? (defining_msc_reference)*
+;
+
+defining_msc_reference:
+ 'reference' (virtuality)? NAME
+;
+
+virtuality:
+ 'virtual' | 'redefined' | 'finalized'
+;
+
+using_clause:
+ ('using' instance_kind end)*
+;
+
+containing_clause:
+ ('inst' instance_item)+
+;
+
+instance_item:
+ NAME (':' instance_kind)? (inheritance)?
+ (decomposition)?
+ (dynamic_decl_list | end)
+;
+
+inheritance:
+ 'inherits' instance_kind
+;
+
+message_decl_clause:
+ ('msg' message_decl end)*
+;
+
+timer_decl_clause:
+ ('timer' timer_decl end)*
+;
+
+sdl_reference:
+ identifier
+;
+
+identifier:
+ (Qualifier)? NAME
+;
+
+
+// ----- Basic MSC
+
+message_sequence_chart:
+ {
+ init(context);
+ }
+ (virtuality)? 'msc' msc_head (msc | hmsc) 'endmsc' end
+ {
+ msc_was_read_fun(context);
+ check_collections_fun(context);
+ }
+;
+
+msc:
+ {
+ new_bmsc_fun(context);
+ }
+ msc_body
+;
+
msc_head:
NAME
{
- set_msc_name_fun(context, (char*) $NAME.text->chars);
+ set_msc_name_fun(context, (char*) $NAME.text->chars);
}
(msc_parameter_decl)? (time_offset)? end
(msc_inst_interface)? msc_gate_interface
@@ -100,11 +429,11 @@
;
msc_inst_interface:
-// containing_clause
+ containing_clause
;
instance_kind:
- (kind_denominator)? //identifier
+ (kind_denominator)? identifier
;
kind_denominator:
@@ -133,110 +462,130 @@
;
create_gate:
- def_create_in_gate | def_create_out_gate
+ def_create_in_gate | def_create_out_gate
;
order_gate:
def_order_in_gate | def_order_out_gate
;
-msc:
- {
- new_bmsc_fun(context);
- }
- msc_body
-;
-
msc_body:
(msc_statement)*
;
msc_statement:
- text_definition | event_definition
+ text_definition | event_definition
;
event_definition:
- NAME
+ NAME
{
set_instance_name_fun(context, (char*) ($NAME.text->chars));
}
- ':' instance_event_list end
- | instance_name_list ':' multi_instance_event_list end
+ ':' instance_event_list
+ | instance_name_list ':' multi_instance_event_list
;
instance_event_list:
(instance_event)+
;
+instance_event:
+ orderable_event | non_orderable_event
+;
+
+orderable_event:
+ ('label' NAME end
+ {
+ set_event_name_fun(context, (char*) ($NAME.text->chars));
+ })?
+ (message_event | incomplete_message_event |
+ method_call_event | incomplete_method_call_event | create |
+ timer_statement | action)
+ ('before' order_dest_list
+ {
+ add_before_relation_fun(context);
+ })?
+ ('after' order_dest_list
+ {
+ add_after_relation_fun(context);
+ })? end
+ ('time' time_dest_list end)?
+;
+
+order_dest_list:
+ order_dest (',' order_dest_list)?
+;
+
+time_dest_list:
+ (time_dest ('origin')?)? time_interval (',' time_dest_list)?
+;
+
+time_dest:
+ NAME | ('top' | 'bottom') (reference_identification | NAME)
+;
+
+non_orderable_event:
+ start_method
+ | end_method
+ | start_suspension
+ | end_suspension
+ | start_coregion { start_coregion_fun(context); }
+ | end_coregion { end_coregion_fun(context); }
+ | shared_condition
+ | shared_msc_reference
+ | shared_inline_expr
+ | instance_head_statement { new_instance_fun(context); }
+ | instance_end_statement
+ | stop
+;
+
instance_name_list:
NAME (',' NAME)* | 'all'
;
-instance_event:
- orderable_event | non_orderable_event
+multi_instance_event_list:
+ (multi_instance_event)+
;
-orderable_event:
- ('label' NAME end
- {
- add_event_name_fun(context, (char*) ($NAME.text->chars));
- })?
- (message_event
- | incomplete_message_event
-// | method_call_event
-// | incomplete_method_call_event
- | create
-// | timer_statement
- | action)
+multi_instance_event:
+ condition | msc_reference | inline_expr
+;
- ('before' order_dest_list
- {
- add_before_relation_fun(context);
- })?
- ('after' order_dest_list
- {
- add_after_relation_fun(context);
- })?
+// ----- Instance
- ('time' time_dest_list end)?
+instance_head_statement:
+ 'instance' (instance_kind)? (decomposition)? end
;
+instance_end_statement:
+ 'endinstance' end
+;
+
+
+// ----- Message
+
message_event:
- message_output | message_input
+ message_output | message_input
;
message_output:
- 'out' msg_identification 'to' input_address
-
+ 'out' msg_identification 'to' input_address
{
- message_output_fun(context, (char *)$msg_identification.text->chars);
+ message_output_fun(context, (char *)$msg_identification.text->chars);
}
;
message_input:
'in' msg_identification 'from' output_address
-
{
- message_input_fun(context, (char *)$msg_identification.text->chars);
+ message_input_fun(context, (char *)$msg_identification.text->chars);
}
;
-msg_identification:
- NAME (',' NAME)? ('(' parameter_list ')')?
-;
-
-input_address:
- NAME | ('env' | reference_identification) ('via' NAME)?
-;
-
-output_address:
- NAME | ('env' | reference_identification) ('via' NAME)?
-;
-
incomplete_message_event:
- incomplete_message_output
- | incomplete_message_input
+ incomplete_message_output | incomplete_message_input
;
incomplete_message_output:
@@ -253,608 +602,482 @@
}
;
-time_dest_list:
- (time_dest ('origin')?)? time_interval (',' time_dest_list)?
+msg_identification:
+ NAME (',' NAME)? ('(' parameter_list ')')?
;
-time_dest:
- NAME | ('top' | 'bottom') (reference_identification | NAME)
+output_address:
+ NAME | ('env' | reference_identification) ('via' NAME)?
;
-multi_instance_event_list:
- (multi_instance_event)+
+reference_identification:
+ 'reference' msc_reference_identification
+ | 'inline' inline_expr_identification
;
-multi_instance_event:
- condition | //msc_reference | inline_expr
+input_address:
+ NAME | ('env' | reference_identification) ('via' NAME)?
;
-order_dest_list:
- order_dest (',' order_dest_list)?
+// ----- Control Flow
+
+method_call_event:
+ call_out | call_in | reply_out | reply_in
;
-order_dest:
- NAME
- {
- add_order_event_fun(context, (char*) $NAME.text->chars);
- }
- | ('env' | reference_identification) 'via' NAME
+call_out:
+ 'call' msg_identification 'to' input_address
;
-reference_identification:
- 'reference' msc_reference_identification
- | 'inline' inline_expr_identification
+call_in:
+ 'receive' msg_identification 'from' output_address
;
-msc_reference_identification:
- NAME
+reply_out:
+ 'replyout' msg_identification 'to' input_address
;
-inline_expr_identification:
- NAME
+
+reply_in:
+ 'replyin' msg_identification 'from' output_address
;
-non_orderable_event:
- instance_head_statement
- {
- new_instance_fun(context);
- }
- | instance_end_statement
- | start_coregion
- {
- start_coregion_fun(context);
- }
- | end_coregion
- {
- end_coregion_fun(context);
- }
- | start_method
- | end_method
- | start_suspension
- | end_suspension
- | shared_condition
- | shared_msc_reference
-// | shared_inline_expr ak sa odkomentuje tak sa zacykli
- | stop
+incomplete_method_call_event:
+ incomplete_call_out | incomplete_call_in |
+ incomplete_reply_out | incomplete_reply_in
;
-instance_head_statement:
- 'instance' //(instance_kind)?
- //(decomposition)?
- //end pravdepodobne tam nema byt
+incomplete_call_out:
+ 'call' msg_identification 'to' 'lost' (input_address)?
;
-instance_end_statement:
- 'endinstance' // end pravdepodobne tam nema byt
+incomplete_call_in:
+ 'receive' msg_identification 'from' 'found' (output_address)?
;
-start_coregion:
- 'concurrent' // end pravdepodobne tam nema byt
+incomplete_reply_out:
+ 'replyout' msg_identification 'to' 'lost' (input_address)?
;
-end_coregion:
- 'endconcurrent' // end pravdepodobne tam nema byt
+incomplete_reply_in:
+ 'replyin' msg_identification 'from' 'found' (output_address)?
;
-end:
- (comment)? ';'
+start_method:
+ 'method' end
;
-comment:
- 'comment' Character_String
+end_method:
+ 'endmethod' end
;
-/*
- * HMsc
- */
+start_suspension:
+ 'suspension' end
+;
-hmsc:
- {
- new_hmsc_fun(context);
- }
- hmsc_body
+end_suspension:
+ 'endsuspension' end
;
-hmsc_body:
- (hmsc_statement)*
+
+// ----- Environment and Gates
+
+actual_out_gate:
+ (NAME)? 'out' msg_identification 'to' input_dest
;
-hmsc_statement:
- text_definition | node_definition
+actual_in_gate:
+ (NAME)? 'in' msg_identification 'from' output_dest
;
-text_definition:
- 'text' Character_String end
+input_dest:
+ 'lost' (input_address)? | input_address
;
-node_definition:
- initial_node | final_node | intermediate_node
+output_dest:
+ 'found' (output_address)? | output_address
;
-initial_node:
- 'initial' connection_list end
- {
- new_start_node_fun(context);
- }
+def_in_gate:
+ (NAME)? 'out' msg_identification 'to' input_dest
;
-final_node:
- NAME ':' 'final'
- {
- new_end_node_fun(context, (char*) ($NAME.text->chars));
- }
- end
+def_out_gate:
+ (NAME)? 'in' msg_identification 'from' output_dest
;
-connection_list:
- 'connect' label_list
+actual_order_out_gate:
+ NAME 'before' order_dest
;
-label_list:
- NAME
+order_dest:
+ NAME
{
- add_connect_name_fun(context, (char*) ($NAME.text->chars));
+ add_order_event_fun(context, (char*) $NAME.text->chars);
}
- (',' label_list)? //POZOR!!! upravena gramatika
+ | ('env' | reference_identification) 'via' NAME
;
-intermediate_node:
+actual_order_in_gate:
NAME
- {
- set_node_name_fun(context, (char*) ($NAME.text->chars));
- }
- ':' intermediate_node_type connection_list end
- {
- switch (get_node_type_fun(context))
- {
- case 0:
- new_reference_node_fun(context);
- break;
- case 1:
- new_connection_node_fun(context);
- break;
- case 2:
- new_condition_node_fun(context);
- break;
- //default:
- //bug report
- }
-
- }
+ ('after' order_dest_list)?
;
-intermediate_node_type:
- timeable_node | untimeable_node
+def_order_in_gate:
+ NAME 'before' order_dest
;
-untimeable_node:
- hmsc_connection_node
- {
- set_connection_node_fun(context);
- }
- | hmsc_condition_node
- {
- set_condition_node_fun(context);
- }
+def_order_out_gate:
+ NAME
+ ('after' order_dest_list)?
;
-hmsc_connection_node:
- /* empty */
+actual_create_out_gate:
+ 'create' 'out' create_gate_identification 'create' create_target
;
-hmsc_condition_node:
- condition_identification (shared)?
+actual_create_in_gate:
+ 'create' 'in' create_gate_identification
;
-timeable_node:
-// (hmsc_ref_expr_node | hmsc_expression)?
-hmsc_ref_expr_node
-// ('time' time_interval end)?
-// ('top' time_dest_list end)?
-// ('bottom' time_dest_list end)?
+create_target:
+ NAME | ('env' | reference_identification) ('via' NAME)?
;
-hmsc_ref_expr_node:
- 'reference' (msc_reference_identification ':')? msc_ref_expr
+def_create_in_gate:
+ 'create' 'out' (create_gate_identification)? 'create' create_target
;
-hmsc_expression:
- (hmsc_loop_expr | hmsc_opt_expr | hmsc_alt_expr |
- hmsc_seq_expr | hmsc_par_expr | hmsc_exc_expr)
+def_create_out_gate:
+ 'create' 'in' create_gate_identification
;
-msc_ref_expr:
- msc_ref_par_expr ('alt' msc_ref_par_expr)*
+inline_out_gate:
+ def_out_gate
+ ('external' 'out' msg_identification 'to' input_dest)?
;
-msc_ref_par_expr:
- msc_ref_seq_expr ('par' msc_ref_seq_expr)*
+inline_in_gate:
+ def_in_gate
+ ('external' 'in' msg_identification 'from' output_dest)?
;
-msc_ref_seq_expr:
- msc_ref_ident_expr ('seq' msc_ref_ident_expr)*
+inline_out_call_gate:
+ def_out_call_gate
+ ('external' 'call' msg_identification 'to' input_dest)?
;
-msc_ref_ident_expr:
- 'loop' (loop_boundary)? msc_ref_ident_expr |
- 'exc' msc_ref_ident_expr |
- 'opt' msc_ref_ident_expr |
- 'empty' |
- (parent)* NAME
- {
- set_reference_name_fun(context, (char*) ($NAME.text->chars));
- }
- (actual_parameters)? | '(' msc_ref_expr ')'
+inline_in_call_gate:
+ def_in_call_gate
+ ('external' 'receive' msg_identification 'from' output_dest)?
;
-hmsc_loop_expr:
- 'loop' (loop_boundary)? 'begin' (inline_expr_identification)? end
- hmsc_body
- 'loop' 'end'
+inline_out_reply_gate:
+ def_out_reply_gate
+ ('external' 'replyout' msg_identification 'to' input_dest)?
;
-hmsc_opt_expr:
- 'opt' 'begin' (inline_expr_identification)? end
- hmsc_body
- 'opt' 'end'
+inline_in_reply_gate:
+ def_in_reply_gate
+ ('external' 'replyin' msg_identification 'from' output_dest)?
;
-hmsc_alt_expr:
- 'alt' 'begin' (inline_expr_identification)? end
- hmsc_body
- ('alt' end hmsc_body)*
- 'alt' 'end'
+inline_create_out_gate:
+ def_create_out_gate
+ ('external' create)?
;
-hmsc_seq_expr:
- 'seq' 'begin' (inline_expr_identification)? end
- hmsc_body
- ('seq' end hmsc_body)*
- 'seq' 'end'
+inline_create_in_gate:
+ def_create_in_gate
+ ('external' 'create' 'from' create_source)?
;
-hmsc_par_expr:
- 'par' 'begin' (inline_expr_identification)? end
- hmsc_body
- ('par' end hmsc_body)*
- 'par' 'end'
+create_source:
+ NAME |
+ ('env' | reference_identification) ('via' create_gate_identification)?
;
-hmsc_exc_expr:
- 'exc' 'begin' (inline_expr_identification)? end
- hmsc_body
- 'exc' 'end'
+inline_order_out_gate:
+ NAME
+ (('after' order_dest_list)? 'external' 'before' order_dest)?
;
-parent:
- '#'
+inline_order_in_gate:
+ NAME 'before' order_dest
+ ('external' ('after' order_dest_list)?)?
;
-actual_parameters:
- '(' actual_parameters_list ')'
+actual_out_call_gate:
+ (NAME)? 'call' msg_identification 'to' input_dest
;
-actual_parameters_list:
- actual_parameters_block (end actual_parameters_list)?
+actual_in_call_gate:
+ (NAME)? 'receive' msg_identification 'from' output_dest
;
-actual_parameters_block:
- actual_data_parameters
- | actual_instance_parameters
- | actual_message_parameters
- | actual_timer_parameters
+def_in_call_gate:
+ (NAME)? 'call' msg_identification 'to' input_dest
;
-actual_instance_parameters:
- 'inst' actual_instance_parm_list
+def_out_call_gate:
+ (NAME)? 'receive' msg_identification 'from' output_dest
;
-actual_instance_parm_list:
- actual_instance_parameter (',' actual_instance_parm_list)?
+actual_out_reply_gate:
+ (NAME)? 'replyout' msg_identification 'to' input_dest
;
-actual_instance_parameter:
- NAME
+actual_in_reply_gate:
+ (NAME)? 'replyin' msg_identification 'from' output_dest
;
-actual_message_parameters:
- 'msg' actual_message_list
+def_in_reply_gate:
+ (NAME)? 'replyout' msg_identification 'to' input_dest
;
-actual_message_list:
- NAME (',' actual_message_list)?
+def_out_reply_gate:
+ (NAME)? 'replyin' msg_identification 'from' output_dest
;
-actual_timer_parameters:
- 'timer' actual_timer_list
+gate_identification:
+ NAME
;
-actual_timer_list:
- NAME (',' actual_timer_list)?
+create_gate_identification:
+ (gate_identification ':')? instance_kind
;
-/*
- * Enviroment and Gates
- */
-def_in_gate:
- (NAME)? 'out' msg_identification 'to' input_dest
-;
+// ----- Condition
-def_out_gate:
- (NAME)? 'in' msg_identification 'from' output_dest
+shared_condition:
+ (shared)? condition_identification shared end
;
-def_in_call_gate:
- (NAME)? 'call' msg_identification 'to' input_dest
+condition_identification:
+ 'condition' condition_text
;
-def_out_call_gate:
- (NAME)? 'receive' msg_identification 'from' output_dest
+condition_text:
+ condition_name_list | 'when' (condition_name_list | '(' expression ')') |
+ 'otherwise'
;
-def_in_reply_gate:
- (NAME)? 'replyout' msg_identification 'to' input_dest
+condition_name_list:
+ name = NAME
+ {
+ set_condition_name_fun(context, (char*) $name.text->chars);
+ }
+ (',' NAME)*
;
-def_out_reply_gate:
- (NAME)? 'replyin' msg_identification 'from' output_dest
+shared:
+ 'shared' ((shared_instance_list)? | 'all')
;
-def_create_in_gate:
- 'create' 'out' (create_gate_identification)? 'create' create_target
+shared_instance_list:
+ NAME (',' shared_instance_list)?
;
-def_create_out_gate:
- 'create' 'in' create_gate_identification
+condition:
+ (shared)? condition_identification end
;
-def_order_in_gate:
-// NAME 'before' order_dest
-;
-def_order_out_gate:
- NAME ('after' order_dest_list)?
-;
+// ----- Timer
-create_target:
- NAME | ('env' | reference_identification) ('via' NAME)?
+timer_statement:
+ starttimer | stoptimer | timeout
;
-create_gate_identification:
-// (gate_identification ':')? instance_kind
+starttimer:
+ 'starttimer' NAME (',' NAME)?
+ (duration)? ('(' parameter_list ')')?
;
-gate_identification:
- NAME
+duration:
+ Left_Square_Bracket
+ (durationlimit)? (',' durationlimit)? Right_Square_Bracket
;
-input_dest:
- 'lost' (input_address)? | input_address
+durationlimit:
+ STRING | 'inf'
;
-output_dest:
- 'found' (output_address)? | output_address
+stoptimer:
+ 'stoptimer' NAME (',' NAME)?
;
-/*
- * Control Flow
- */
-method_call_event:
- call_out | call_in | reply_out | reply_in
+timeout:
+ 'timeout' NAME (',' NAME)?
+ ('(' parameter_list ')')?
;
-call_out:
- 'call' msg_identification 'to' input_address
-;
-call_in:
- 'receive' msg_identification 'from' output_address
+// ----- Action
+
+action:
+ 'action' action_statement
;
-reply_out:
- 'replyout' msg_identification 'to' input_address
+action_statement:
+ informal_action | data_statement_list
;
-reply_in:
- 'replyin' msg_identification 'from' output_address
+informal_action:
+ Character_String
;
-incomplete_method_call_event:
- incomplete_call_out | incomplete_call_in |
- incomplete_reply_out | incomplete_reply_in
+
+// ----- Instance creation
+
+create:
+ 'create' NAME ('(' parameter_list ')')?
;
-incomplete_call_out:
- 'call' msg_identification 'to' 'lost' (input_address)?
+
+// ----- Instance stop
+
+stop:
+ 'stop' end
;
-incomplete_call_in:
- 'receive' msg_identification 'from' 'found' (output_address)?
+
+// ----- Data concepts
+
+parenthesis_declaration:
+// 'parenthesis' par_decl_list end
;
-incomplete_reply_out:
- 'replyout' msg_identification 'to' 'lost' (input_address)?
+par_decl_list:
+ (nestable_par_pair | non_nestable_par_pair | equal_par_decl | escape_decl)
+ (par_decl_list)?
;
-incomplete_reply_in:
- 'replyin' msg_identification 'from' 'found' (output_address)?
+nestable_par_pair:
+ 'nestable' pair_par_list end
;
-start_method:
- 'method' end
+non_nestable_par_pair:
+ 'nonnestable' pair_par_list end
;
-end_method:
- 'endmethod' end
+equal_par_decl:
+ 'equalpar' equal_par_list end
;
-start_suspension:
- 'suspension' end
+escape_decl:
+ 'escape' Escapechar
;
-end_suspension:
- 'endsuspension' end
+pair_par_list:
+ pair_par (escape_decl)? (',' pair_par_list)?
;
-/*
- * Inline expression
- */
-
-shared_inline_expr:
-/* (extra_global)? (shared_loop_expr | shared_opt_expr |
- shared_alt_expr | shared_seq_expr | shared_par_expr | shared_exc_expr)
- ('time' time_interval end)?
- ('top' time_dest_list end)?
- ('bottom' time_dest_list end)?
-*/
+pair_par:
+ Delim Par Delim Par Delim
;
-extra_global:
- 'external'
+equal_par_list:
+ equal_par (escape_decl)? (',' equal_par_list)?
;
-shared_loop_expr:
-/* 'loop' (loop_boundary)? 'begin' (inline_expr_identification)? shared end
- (inline_gate_interface)? (instance_event_list)?
- 'loop' 'end' end
-*/
+equal_par:
+ Delim Par Delim
;
-shared_opt_expr:
-/* 'opt' 'begin' (inline_expr_identification)? shared end
- (inline_gate_interface)? (instance_event_list)?
- 'opt' 'end' end
-*/
+Delim:
+ Apostrophe
+ | Alphanumeric
+ | Other_Character
+ | Special
+ | Full_Stop
+ | Underline
;
-shared_exc_expr:
-/* 'exc' 'begin' (inline_expr_identification)? shared end
- (inline_gate_interface)? (instance_event_list)?
- 'exc' 'end' end
-*/
+Par:
+ Character_String
;
-shared_alt_expr:
- 'alt' 'begin' (inline_expr_identification)? shared end
- (inline_gate_interface)? (instance_event_list)?
- ('alt' end (inline_gate_interface)? (instance_event_list)?)*
- 'alt' 'end' end
+Escapechar:
+// Delim Character_String Delim
;
-shared_seq_expr:
- 'seq' 'begin' (inline_expr_identification)? shared end
- (inline_gate_interface)? (instance_event_list)?
- ('seq' end (inline_gate_interface)? (instance_event_list)?)*
- 'seq' 'end' end
+
+// ----- Declaring data
+
+message_decl_list:
+ message_decl (end message_decl_list)?
;
-shared_par_expr:
- 'par' 'begin' (inline_expr_identification)? shared end
- (inline_gate_interface)? (instance_event_list)?
- ('par' end (inline_gate_interface)? (instance_event_list)?)*
- 'par' 'end' (time_interval)? end
+message_decl:
+ message_name_list (':' '(' type_ref_list ')')?
;
-inline_expr:
- (extra_global)? (loop_expr | opt_expr | alt_expr |
- seq_expr | par_expr | exc_expr)
- ('time' time_interval end)?
- ('top' time_dest_list end)?
- ('bottom' time_dest_list end)?
+message_name_list:
+ NAME (',' message_name_list)?
;
-loop_expr:
- 'loop' (loop_boundary)? 'begin' (inline_expr_identification)? end
- (inline_gate_interface)? msc_body
- 'loop' 'end' end
+timer_decl_list:
+ timer_decl (end timer_decl_list)?
;
-opt_expr:
- 'opt' 'begin' (inline_expr_identification)? end
- (inline_gate_interface)? msc_body
- 'opt' 'end' end
+timer_decl:
+ timer_name_list (duration)? (':' '(' type_ref_list ')')?
;
-exc_expr:
- 'exc' 'begin' (inline_expr_identification)? end
- (inline_gate_interface)? msc_body
- 'exc' 'end' end
+timer_name_list:
+ NAME (',' timer_name_list)?
;
-alt_expr:
- 'alt' 'begin' (inline_expr_identification)? end
- (inline_gate_interface)? msc_body
- ('alt' end (inline_gate_interface)? msc_body)*
- 'alt' 'end' end
-
+type_ref_list:
+ STRING (',' type_ref_list)?
;
-seq_expr:
- 'seq' 'begin' (inline_expr_identification)? end
- (inline_gate_interface)? msc_body
- ('seq' end (inline_gate_interface)? msc_body)*
- 'seq' 'end' end
+dynamic_decl_list:
+ 'variables' variable_decl_list end
;
-par_expr:
- 'par' 'begin' (inline_expr_identification)? end
- (inline_gate_interface)? msc_body
- ('par' end (inline_gate_interface)? msc_body)*
- 'par' 'end' end
+variable_decl_list:
+ variable_decl_item (end variable_decl_list)?
;
-loop_boundary:
- Left_Angular_Bracket inf_natural (',' inf_natural)?
- Right_Angular_Bracket
+variable_decl_item:
+ variable_list ':' STRING
;
-inf_natural:
- 'inf' | expression
+variable_list:
+ STRING (',' variable_list)?
;
-inline_gate_interface:
- ('gate' inline_gate end)+
+data_definition:
+ ('language' NAME end)?
+ (wildcard_decl)?
+ ('data' STRING end)?
;
-inline_gate:
-/* inline_out_gate | inline_in_gate |
- inline_create_out_gate | inline_create_in_gate |
- inline_out_call_gate | inline_in_call_gate |
- inline_out_reply_gate | inline_in_reply_gate |
- inline_order_out_gate | inline_order_in_gate
-*/
+wildcard_decl:
+ 'wildcards' variable_decl_list end
;
-/*
- * MSC reference
- */
-shared_msc_reference:
- 'reference' (msc_reference_identification ':')?
-// msc_ref_expr shared end
- ('time' time_interval end)?
- ('top' time_dest_list end)?
- ('bottom' time_dest_list end)?
- reference_gate_interface
+
+// ----- Static Data
+
+data_parameter_decl:
+ ('variables')? variable_decl_list
;
-reference_gate_interface:
- (end 'gate' ref_gate)*
+actual_data_parameters:
+ ('variables')? actual_data_parameter_list
;
-ref_gate:
-/* actual_out_gate | actual_in_gate |
- actual_order_out_gate | actual_order_in_gate |
- actual_create_out_gate | actual_create_in_gate |
- actual_out_call_gate | actual_in_call_gate |
- actual_out_reply_gate | actual_in_reply_gate
-*/
+actual_data_parameter_list:
+ STRING (',' actual_data_parameter_list)?
;
-/*
- * Bindings
- */
+// ----- Bindings
+
binding:
left_binding | right_binding
;
@@ -863,14 +1086,14 @@
pattern LEFT_BIND_SYMBOL expression
;
+LEFT_BIND_SYMBOL:
+ ':='
+;
+
right_binding:
expression RIGHT_BIND_SYMBOL pattern
;
-LEFT_BIND_SYMBOL:
- ':='
-;
-
RIGHT_BIND_SYMBOL:
'=:'
;
@@ -887,58 +1110,20 @@
STRING
;
-/*
- * Static Data
- */
-data_parameter_decl:
- ('variables')? variable_decl_list
-;
+// ----- Data in message and timer paramerers
-actual_data_parameters:
- ('variables')? actual_data_parameter_list
+parameter_list:
+ parameter_defn (',' parameter_list)?
;
-actual_data_parameter_list:
- STRING (',' actual_data_parameter_list)?
+parameter_defn:
+ binding | expression | pattern
;
-/*
- * Instance creation
- */
-create:
- 'create' NAME ('(' parameter_list ')')?
-;
+// ----- Data in action boxes
-/*
- * Instance stop
- */
-
-stop:
- 'stop' end
-;
-
-/*
- * Action
- */
-
-action:
- 'action' action_statement
-;
-
-action_statement:
- informal_action | data_statement_list
-;
-
-informal_action:
- Character_String
-;
-
-/*
- * Data in action boxes
- *...
[truncated message content] |