|
From: <got...@us...> - 2008-05-10 21:53:48
|
Revision: 68
http://scstudio.svn.sourceforge.net/scstudio/?rev=68&view=rev
Author: gotthardp
Date: 2008-05-10 14:53:44 -0700 (Sat, 10 May 2008)
Log Message:
-----------
First draft of a Z.120 parser.
Added Paths:
-----------
trunk/src/data/Z120/
trunk/src/data/Z120/CMakeLists.txt
trunk/src/data/Z120/README
trunk/src/data/Z120/Z120.cpp
trunk/src/data/Z120/Z120.g
trunk/src/data/Z120/Z120.h
trunk/src/data/Z120/main.cpp
trunk/src/data/Z120/test.msc
Added: trunk/src/data/Z120/CMakeLists.txt
===================================================================
--- trunk/src/data/Z120/CMakeLists.txt (rev 0)
+++ trunk/src/data/Z120/CMakeLists.txt 2008-05-10 21:53:44 UTC (rev 68)
@@ -0,0 +1,14 @@
+PROJECT(parser C CXX)
+# SET(CMAKE_VERBOSE_MAKEFILE ON)
+
+INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/include)
+
+ADD_EXECUTABLE(parser
+ main.cpp
+ Z120.cpp
+ Z120Lexer.c
+ Z120Parser.c)
+
+TARGET_LINK_LIBRARIES(parser
+ antlr3c)
+
\ No newline at end of file
Added: trunk/src/data/Z120/README
===================================================================
--- trunk/src/data/Z120/README (rev 0)
+++ trunk/src/data/Z120/README 2008-05-10 21:53:44 UTC (rev 68)
@@ -0,0 +1,16 @@
+A.1. Build instructions
+-----------------------
+
+1) Install the ANTLR v3 (http://www.antlr.org)
+ - download immediate build antlr-2008-05-07.18.tar.gz
+ - install the ANTLR tool
+ - install the C runtime library
+
+
+Configure and build the application by executing
+ java org.antlr.Tool Z120.g
+ cmake . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local
+ make
+
+
+$Id: README 31 2007-10-25 17:18:57Z gotthardp $
Added: trunk/src/data/Z120/Z120.cpp
===================================================================
--- trunk/src/data/Z120/Z120.cpp (rev 0)
+++ trunk/src/data/Z120/Z120.cpp 2008-05-10 21:53:44 UTC (rev 68)
@@ -0,0 +1,109 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2008 Petr Gotthard <pet...@ce...>
+ *
+ * $Id: Z120.g 43 2008-04-24 12:05:24Z gotthardp $
+ */
+
+#include "Z120.h"
+
+// Process "Z120.g" with antlr-2008-05-07 to produce the following files.
+#include "Z120Lexer.h"
+#include "Z120Parser.h"
+
+#include <assert.h>
+
+inline std::string getTokenString(pANTLR3_COMMON_TOKEN token)
+{
+ return std::string((char*)token->getStartIndex(token),
+ token->getStopIndex(token)-token->getStartIndex(token)+1);
+}
+
+static void walk(pANTLR3_BASE_TREE tree)
+{
+ assert(tree != NULL);
+ switch(tree->getType(tree))
+ {
+ case NAME:
+ {
+ std::string pp = getTokenString(tree->getToken(tree));
+ printf("NAME %s\n", pp.c_str());
+ break;
+ }
+
+ case MSC:
+ printf("MSC\n");
+ walk((pANTLR3_BASE_TREE)tree->getChild(tree, 0));
+ printf(";\n\n");
+ break;
+
+ default:
+ fprintf(stderr, "Unexpected node<%d>\n", tree->getType(tree));
+ break;
+ }
+}
+
+int Z120::readFile(const std::string& filename)
+{
+ pANTLR3_INPUT_STREAM input =
+ antlr3AsciiFileStreamNew((pANTLR3_UINT8)filename.c_str());
+ if (input == NULL || (int)input < 0)
+ {
+ fprintf(stderr, "Unable to open file %s\n", filename.c_str());
+ exit(1);
+ }
+
+ pZ120Lexer lxr = Z120LexerNew(input);
+
+ if (lxr == NULL)
+ {
+ fprintf(stderr, "Unable to create the lexer\n");
+ exit(1);
+ }
+
+ pANTLR3_COMMON_TOKEN_STREAM tstream =
+ antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, lxr->pLexer->rec->state->tokSource);
+ if (tstream == NULL)
+ {
+ fprintf(stderr, "Out of memory trying to allocate token stream\n");
+ exit(1);
+ }
+
+ pZ120Parser psr = Z120ParserNew(tstream);
+ if (psr == NULL)
+ {
+ fprintf(stderr, "Out of memory trying to allocate parser\n");
+ exit(1);
+ }
+
+ struct Z120Parser_textual_msc_file_return_struct langAST =
+ psr->textual_msc_file(psr);
+ if (psr->pParser->rec->state->errorCount > 0)
+ {
+ fprintf(stderr, "The parser returned %d errors, tree walking aborted.\n", psr->pParser->rec->state->errorCount);
+ }
+ else
+ {
+ walk(langAST.tree);
+ }
+
+ psr->free(psr); psr = NULL;
+ tstream->free(tstream); tstream = NULL;
+ lxr->free(lxr); lxr = NULL;
+ input->close(input); input = NULL;
+
+ return 0;
+}
+
+// end of file
Added: trunk/src/data/Z120/Z120.g
===================================================================
--- trunk/src/data/Z120/Z120.g (rev 0)
+++ trunk/src/data/Z120/Z120.g 2008-05-10 21:53:44 UTC (rev 68)
@@ -0,0 +1,1475 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2008 Petr Gotthard <pet...@ce...>
+ *
+ * $Id: Z120.g 43 2008-04-24 12:05:24Z gotthardp $
+ */
+
+grammar Z120;
+
+options
+{
+ output = AST;
+ language = C;
+ backtrack = true;
+}
+
+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
+;
+
+Non_Parenthesis:
+ (Non_Par_Non_Escape /*|
+ escapechar (escapechar | par)*/)
+;
+
+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:
+ (message_sequence_chart)*
+;
+
+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:
+ (virtuality)? 'msc' msc_head (msc | hmsc) 'endmsc' end
+;
+
+msc:
+ msc_body
+;
+
+msc_head:
+ NAME (msc_parameter_decl)? (time_offset)? end
+ (msc_inst_interface)? msc_gate_interface
+;
+
+msc_parameter_decl:
+ '(' msc_parm_decl_list ')'
+;
+
+msc_parm_decl_list:
+ msc_parm_decl_block (end msc_parm_decl_list)?
+;
+
+msc_parm_decl_block:
+ data_parameter_decl
+ | instance_parameter_decl
+ | message_parameter_decl
+ | timer_parameter_decl
+;
+
+instance_parameter_decl:
+ 'inst' instance_parm_decl_list
+;
+
+instance_parm_decl_list:
+ instance_parameter_name (':' instance_kind)? (',' instance_parm_decl_list)?
+;
+
+instance_parameter_name:
+ NAME
+;
+
+message_parameter_decl:
+ 'msg' message_parm_decl_list
+;
+
+message_parm_decl_list:
+ message_decl_list
+;
+
+timer_parameter_decl:
+ 'timer' timer_parm_decl_list
+;
+
+timer_parm_decl_list:
+ timer_decl_list
+;
+
+msc_inst_interface:
+ containing_clause
+;
+
+instance_kind:
+ (kind_denominator)? identifier
+;
+
+kind_denominator:
+ NAME
+;
+
+msc_gate_interface:
+ (msc_gate_def)*
+;
+
+msc_gate_def:
+ 'gate' (msg_gate | method_call_gate | reply_gate |
+ create_gate | order_gate) end
+;
+
+msg_gate:
+ def_in_gate | def_out_gate
+;
+
+method_call_gate:
+ def_out_call_gate | def_in_call_gate
+;
+
+reply_gate:
+ def_out_reply_gate | def_in_reply_gate
+;
+
+create_gate:
+ def_create_in_gate | def_create_out_gate
+;
+
+order_gate:
+ def_order_in_gate | def_order_out_gate
+;
+
+msc_body:
+ (msc_statement)*
+;
+
+msc_statement:
+ text_definition | event_definition
+;
+
+event_definition:
+ NAME ':' 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)?
+ (message_event | incomplete_message_event |
+ method_call_event | incomplete_method_call_event | create |
+ timer_statement | action)
+ ('before' order_dest_list)? ('after' order_dest_list)? 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 | end_coregion | shared_condition |
+ shared_msc_reference | shared_inline_expr |
+ instance_head_statement | instance_end_statement | stop
+;
+
+instance_name_list:
+ NAME (',' NAME)* | 'all'
+;
+
+multi_instance_event_list:
+ (multi_instance_event)+
+;
+
+multi_instance_event:
+ condition | msc_reference | inline_expr
+;
+
+
+// ----- Instance
+
+instance_head_statement:
+ 'instance' (instance_kind)? (decomposition)? end
+;
+
+instance_end_statement:
+ 'endinstance' end
+;
+
+
+// ----- Message
+
+message_event:
+ message_output | message_input
+;
+
+message_output:
+ 'out' msg_identification 'to' input_address
+;
+
+message_input:
+ 'in' msg_identification 'from' output_address
+;
+
+incomplete_message_event:
+ incomplete_message_output | incomplete_message_input
+;
+
+incomplete_message_output:
+ 'out' msg_identification 'to' 'lost' (input_address)?
+;
+
+incomplete_message_input:
+ 'in' msg_identification 'from' 'found' (output_address)?
+;
+
+msg_identification:
+ NAME (',' NAME)? ('(' parameter_list ')')?
+;
+
+output_address:
+ NAME | ('env' | reference_identification) ('via' NAME)?
+;
+
+reference_identification:
+ 'reference' msc_reference_identification
+ | 'inline' inline_expr_identification
+;
+
+input_address:
+ NAME | ('env' | reference_identification) ('via' NAME)?
+;
+
+
+// ----- Control Flow
+
+method_call_event:
+ call_out | call_in | reply_out | reply_in
+;
+
+call_out:
+ 'call' msg_identification 'to' input_address
+;
+
+call_in:
+ 'receive' msg_identification 'from' output_address
+;
+
+reply_out:
+ 'replyout' msg_identification 'to' input_address
+;
+
+reply_in:
+ 'replyin' msg_identification 'from' output_address
+;
+
+incomplete_method_call_event:
+ incomplete_call_out | incomplete_call_in |
+ incomplete_reply_out | incomplete_reply_in
+;
+
+incomplete_call_out:
+ 'call' msg_identification 'to' 'lost' (input_address)?
+;
+
+incomplete_call_in:
+ 'receive' msg_identification 'from' 'found' (output_address)?
+;
+
+incomplete_reply_out:
+ 'replyout' msg_identification 'to' 'lost' (input_address)?
+;
+
+incomplete_reply_in:
+ 'replyin' msg_identification 'from' 'found' (output_address)?
+;
+
+start_method:
+ 'method' end
+;
+
+end_method:
+ 'endmethod' end
+;
+
+start_suspension:
+ 'suspension' end
+;
+
+end_suspension:
+ 'endsuspension' end
+;
+
+
+// ----- Environment and Gates
+
+actual_out_gate:
+ (NAME)? 'out' msg_identification 'to' input_dest
+;
+
+actual_in_gate:
+ (NAME)? 'in' msg_identification 'from' output_dest
+;
+
+input_dest:
+ 'lost' (input_address)? | input_address
+;
+
+output_dest:
+ 'found' (output_address)? | output_address
+;
+
+def_in_gate:
+ (NAME)? 'out' msg_identification 'to' input_dest
+;
+
+def_out_gate:
+ (NAME)? 'in' msg_identification 'from' output_dest
+;
+
+actual_order_out_gate:
+ NAME 'before' order_dest
+;
+
+order_dest:
+ NAME | ('env' | reference_identification) 'via' NAME
+;
+
+actual_order_in_gate:
+ NAME
+ ('after' order_dest_list)?
+;
+
+def_order_in_gate:
+ NAME 'before' order_dest
+;
+
+def_order_out_gate:
+ NAME
+ ('after' order_dest_list)?
+;
+
+actual_create_out_gate:
+ 'create' 'out' create_gate_identification 'create' create_target
+;
+
+actual_create_in_gate:
+ 'create' 'in' create_gate_identification
+;
+
+create_target:
+ NAME | ('env' | reference_identification) ('via' NAME)?
+;
+
+def_create_in_gate:
+ 'create' 'out' (create_gate_identification)? 'create' create_target
+;
+
+def_create_out_gate:
+ 'create' 'in' create_gate_identification
+;
+
+inline_out_gate:
+ def_out_gate
+ ('external' 'out' msg_identification 'to' input_dest)?
+;
+
+inline_in_gate:
+ def_in_gate
+ ('external' 'in' msg_identification 'from' output_dest)?
+;
+
+inline_out_call_gate:
+ def_out_call_gate
+ ('external' 'call' msg_identification 'to' input_dest)?
+;
+
+inline_in_call_gate:
+ def_in_call_gate
+ ('external' 'receive' msg_identification 'from' output_dest)?
+;
+
+inline_out_reply_gate:
+ def_out_reply_gate
+ ('external' 'replyout' msg_identification 'to' input_dest)?
+;
+
+inline_in_reply_gate:
+ def_in_reply_gate
+ ('external' 'replyin' msg_identification 'from' output_dest)?
+;
+
+inline_create_out_gate:
+ def_create_out_gate
+ ('external' create)?
+;
+
+inline_create_in_gate:
+ def_create_in_gate
+ ('external' 'create' 'from' create_source)?
+;
+
+create_source:
+ NAME |
+ ('env' | reference_identification) ('via' create_gate_identification)?
+;
+
+inline_order_out_gate:
+ NAME
+ (('after' order_dest_list)? 'external' 'before' order_dest)?
+;
+
+inline_order_in_gate:
+ NAME 'before' order_dest
+ ('external' ('after' order_dest_list)?)?
+;
+
+actual_out_call_gate:
+ (NAME)? 'call' msg_identification 'to' input_dest
+;
+
+actual_in_call_gate:
+ (NAME)? 'receive' msg_identification 'from' output_dest
+;
+
+def_in_call_gate:
+ (NAME)? 'call' msg_identification 'to' input_dest
+;
+
+def_out_call_gate:
+ (NAME)? 'receive' msg_identification 'from' output_dest
+;
+
+actual_out_reply_gate:
+ (NAME)? 'replyout' msg_identification 'to' input_dest
+;
+
+actual_in_reply_gate:
+ (NAME)? 'replyin' msg_identification 'from' output_dest
+;
+
+def_in_reply_gate:
+ (NAME)? 'replyout' msg_identification 'to' input_dest
+;
+
+def_out_reply_gate:
+ (NAME)? 'replyin' msg_identification 'from' output_dest
+;
+
+gate_identification:
+ NAME
+;
+
+create_gate_identification:
+ (gate_identification ':')? instance_kind
+;
+
+
+// ----- Condition
+
+shared_condition:
+ (shared)? condition_identification shared end
+;
+
+condition_identification:
+ 'condition' condition_text
+;
+
+condition_text:
+ condition_name_list | 'when' (condition_name_list | '(' expression ')') |
+ 'otherwise'
+;
+
+condition_name_list:
+ NAME (',' NAME)*
+;
+
+shared:
+ 'shared' ((shared_instance_list)? | 'all')
+;
+
+shared_instance_list:
+ NAME (',' shared_instance_list)?
+;
+
+condition:
+ (shared)? condition_identification end
+;
+
+
+// ----- Timer
+
+timer_statement:
+ starttimer | stoptimer | timeout
+;
+
+starttimer:
+ 'starttimer' NAME (',' NAME)?
+ (duration)? ('(' parameter_list ')')?
+;
+
+duration:
+ Left_Square_Bracket
+ (durationlimit)? (',' durationlimit)? Right_Square_Bracket
+;
+
+durationlimit:
+ STRING | 'inf'
+;
+
+stoptimer:
+ 'stoptimer' NAME (',' NAME)?
+;
+
+timeout:
+ 'timeout' NAME (',' NAME)?
+ ('(' parameter_list ')')?
+;
+
+
+// ----- Action
+
+action:
+ 'action' action_statement
+;
+
+action_statement:
+ informal_action | data_statement_list
+;
+
+informal_action:
+ Character_String
+;
+
+
+// ----- Instance creation
+
+create:
+ 'create' NAME ('(' parameter_list ')')?
+;
+
+
+// ----- Instance stop
+
+stop:
+ 'stop' end
+;
+
+
+// ----- Data concepts
+
+parenthesis_declaration:
+ 'parenthesis' par_decl_list end
+;
+
+par_decl_list:
+ (nestable_par_pair | non_nestable_par_pair | equal_par_decl | escape_decl)
+ (par_decl_list)?
+;
+
+nestable_par_pair:
+ 'nestable' pair_par_list end
+;
+
+non_nestable_par_pair:
+ 'nonnestable' pair_par_list end
+;
+
+equal_par_decl:
+ 'equalpar' equal_par_list end
+;
+
+escape_decl:
+ 'escape' Escapechar
+;
+
+pair_par_list:
+ pair_par (escape_decl)? (',' pair_par_list)?
+;
+
+pair_par:
+ Delim Par Delim Par Delim
+;
+
+equal_par_list:
+ equal_par (escape_decl)? (',' equal_par_list)?
+;
+
+equal_par:
+ Delim Par Delim
+;
+
+Delim:
+ Apostrophe
+ | Alphanumeric
+ | Other_Character
+ | Special
+ | Full_Stop
+ | Underline
+;
+
+Par:
+ Character_String
+;
+
+Escapechar:
+ Delim Character_String Delim
+;
+
+
+// ----- Declaring data
+
+message_decl_list:
+ message_decl (end message_decl_list)?
+;
+
+message_decl:
+ message_name_list (':' '(' type_ref_list ')')?
+;
+
+message_name_list:
+ NAME (',' message_name_list)?
+;
+
+timer_decl_list:
+ timer_decl (end timer_decl_list)?
+;
+
+timer_decl:
+ timer_name_list (duration)? (':' '(' type_ref_list ')')?
+;
+
+timer_name_list:
+ NAME (',' timer_name_list)?
+;
+
+type_ref_list:
+ STRING (',' type_ref_list)?
+;
+
+dynamic_decl_list:
+ 'variables' variable_decl_list end
+;
+
+variable_decl_list:
+ variable_decl_item (end variable_decl_list)?
+;
+
+variable_decl_item:
+ variable_list ':' STRING
+;
+
+variable_list:
+ STRING (',' variable_list)?
+;
+
+data_definition:
+ ('language' NAME end)?
+ (wildcard_decl)?
+ ('data' STRING end)?
+;
+
+wildcard_decl:
+ 'wildcards' variable_decl_list end
+;
+
+
+// ----- Static Data
+
+data_parameter_decl:
+ ('variables')? variable_decl_list
+;
+
+actual_data_parameters:
+ ('variables')? actual_data_parameter_list
+;
+
+actual_data_parameter_list:
+ STRING (',' actual_data_parameter_list)?
+;
+
+
+// ----- Bindings
+
+binding:
+ left_binding | right_binding
+;
+
+left_binding:
+ pattern LEFT_BIND_SYMBOL expression
+;
+
+LEFT_BIND_SYMBOL:
+ ':='
+;
+
+right_binding:
+ expression RIGHT_BIND_SYMBOL pattern
+;
+
+RIGHT_BIND_SYMBOL:
+ '=:'
+;
+
+expression:
+ STRING
+;
+
+pattern:
+ STRING | wildcard
+;
+
+wildcard:
+ STRING
+;
+
+
+// ----- Data in message and timer paramerers
+
+parameter_list:
+ parameter_defn (',' parameter_list)?
+;
+
+parameter_defn:
+ binding | expression | pattern
+;
+
+
+// ----- Data in action boxes
+
+data_statement_list:
+ data_statement (',' data_statement_list)?
+;
+
+data_statement:
+ define_statement | undefine_statement | binding
+;
+
+define_statement:
+ 'def' STRING
+;
+
+undefine_statement:
+ 'undef' STRING
+;
+
+
+// ----- Time Offset
+
+time_offset:
+ 'offset' expression
+;
+
+
+// ----- Time Points
+
+time_point:
+ (Abs_Time_Mark)? expression
+;
+
+
+// ----- Measurements
+
+measurement:
+ rel_measurement
+ | abs_measurement
+;
+
+rel_measurement:
+ Rel_Time_Mark pattern
+;
+
+abs_measurement:
+ Abs_Time_Mark pattern
+;
+
+
+// ----- Time Interval
+
+time_interval:
+ (interval_label)? singular_time
+ | (interval_label)? bounded_time
+ (measurement)?
+;
+
+interval_label:
+ ('int_boundary')? NAME
+;
+
+singular_time:
+ Left_Closed time_point Right_Closed
+ | measurement
+;
+
+bounded_time:
+ (Abs_Time_Mark)? (Left_Open | Left_Closed)
+ (time_point)? ',' (time_point)?
+ (Right_Open | Right_Closed)
+;
+
+
+// ----- Coregion
+
+start_coregion:
+ 'concurrent' end
+;
+
+end_coregion:
+ 'endconcurrent' end
+;
+
+
+// ----- 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)?
+;
+
+extra_global:
+ 'external'
+;
+
+shared_loop_expr:
+ 'loop' (loop_boundary)? 'begin' (inline_expr_identification)? shared end
+ (inline_gate_interface)? (instance_event_list)?
+ 'loop' 'end' end
+;
+
+shared_opt_expr:
+ 'opt' 'begin' (inline_expr_identification)? shared end
+ (inline_gate_interface)? (instance_event_list)?
+ 'opt' 'end' end
+;
+
+shared_exc_expr:
+ 'exc' 'begin' (inline_expr_identification)? shared end
+ (inline_gate_interface)? (instance_event_list)?
+ 'exc' 'end' end
+;
+
+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
+;
+
+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
+;
+
+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
+;
+
+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)?
+;
+
+loop_expr:
+ 'loop' (loop_boundary)? 'begin' (inline_expr_identification)? end
+ (inline_gate_interface)? msc_body
+ 'loop' 'end' end
+;
+
+opt_expr:
+ 'opt' 'begin' (inline_expr_identification)? end
+ (inline_gate_interface)? msc_body
+ 'opt' 'end' end
+;
+
+exc_expr:
+ 'exc' 'begin' (inline_expr_identification)? end
+ (inline_gate_interface)? msc_body
+ 'exc' 'end' end
+;
+
+alt_expr:
+ 'alt' 'begin' (inline_expr_identification)? end
+ (inline_gate_interface)? msc_body
+ ('alt' end (inline_gate_interface)? msc_body)*
+ 'alt' 'end' end
+;
+
+seq_expr:
+ 'seq' 'begin' (inline_expr_identification)? end
+ (inline_gate_interface)? msc_body
+ ('seq' end (inline_gate_interface)? msc_body)*
+ 'seq' 'end' end
+;
+
+par_expr:
+ 'par' 'begin' (inline_expr_identification)? end
+ (inline_gate_interface)? msc_body
+ ('par' end (inline_gate_interface)? msc_body)*
+ 'par' 'end' end
+;
+
+loop_boundary:
+ Left_Angular_Bracket inf_natural (',' inf_natural)?
+ Right_Angular_Bracket
+;
+
+inf_natural:
+ 'inf' | expression
+;
+
+inline_expr_identification:
+ NAME
+;
+
+inline_gate_interface:
+ ('gate' inline_gate 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
+;
+
+
+// ----- 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
+;
+
+msc_reference:
+ 'reference' (msc_reference_identification ':')?
+ msc_ref_expr end
+ ('time' time_interval end)?
+ ('top' time_dest_list end)?
+ ('bottom' time_dest_list end)?
+ reference_gate_interface
+;
+
+msc_reference_identification:
+ NAME
+;
+
+msc_ref_expr:
+ msc_ref_par_expr ('alt' msc_ref_par_expr)*
+;
+
+msc_ref_par_expr:
+ msc_ref_seq_expr ('par' msc_ref_seq_expr)*
+;
+
+msc_ref_seq_expr:
+ msc_ref_ident_expr ('seq' msc_ref_ident_expr)*
+;
+
+msc_ref_ident_expr:
+ 'loop' (loop_boundary)? msc_ref_ident_expr |
+ 'exc' msc_ref_ident_expr |
+ 'opt' msc_ref_ident_expr |
+ 'empty' |
+ (parent)* NAME (actual_parameters)? |
+ '(' msc_ref_expr ')'
+;
+
+actual_parameters:
+ '(' actual_parameters_list ')'
+;
+
+actual_parameters_list:
+ actual_parameters_block (end actual_parameters_list)?
+;
+
+actual_parameters_block:
+ actual_data_parameters
+ | actual_instance_parameters
+ | actual_message_parameters
+ | actual_timer_parameters
+;
+
+actual_instance_parameters:
+ 'inst' actual_instance_parm_list
+;
+
+actual_instance_parm_list:
+ actual_instance_parameter (',' actual_instance_parm_list)?
+;
+
+actual_instance_parameter:
+ NAME
+;
+
+actual_message_parameters:
+ 'msg' actual_message_list
+;
+
+actual_message_list:
+ NAME (',' actual_message_list)?
+;
+
+actual_timer_parameters:
+ 'timer' actual_timer_list
+;
+
+actual_timer_list:
+ NAME (',' actual_timer_list)?
+;
+
+parent:
+ '#'
+;
+
+reference_gate_interface:
+ (end 'gate' ref_gate)*
+;
+
+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
+;
+
+
+// ----- Instance decomposition
+
+decomposition:
+ 'decomposed' (substructure_reference)?
+;
+
+substructure_reference:
+ 'as' NAME
+;
+
+
+// ----- High-level MSC (HMSC)
+
+hmsc:
+ hmsc_body
+;
+
+hmsc_body:
+ (hmsc_statement)*
+;
+
+hmsc_statement:
+ text_definition | node_definition
+;
+
+node_definition:
+ initial_node | final_node | intermediate_node
+;
+
+initial_node:
+ 'initial' connection_list end
+;
+
+final_node:
+ NAME ':' 'final' end
+;
+
+connection_list:
+ 'connect' label_list
+;
+
+label_list:
+ NAME ',' label_list
+;
+
+intermediate_node:
+ NAME ':' intermediate_node_type connection_list end
+;
+
+intermediate_node_type:
+ timeable_node | untimeable_node
+;
+
+untimeable_node:
+ hmsc_connection_node | hmsc_condition_node
+;
+
+hmsc_connection_node:
+ /* empty */
+;
+
+hmsc_condition_node:
+ condition_identification (shared)?
+;
+
+timeable_node:
+ (hmsc_ref_expr_node | hmsc_expression)?
+ ('time' time_interval end)?
+ ('top' time_dest_list end)?
+ ('bottom' time_dest_list end)?
+;
+
+hmsc_ref_expr_node:
+ 'reference' (msc_reference_identification ':')? msc_ref_expr
+;
+
+hmsc_expression:
+ (hmsc_loop_expr | hmsc_opt_expr | hmsc_alt_expr |
+ hmsc_seq_expr | hmsc_par_expr | hmsc_exc_expr)
+;
+
+hmsc_loop_expr:
+ 'loop' (loop_boundary)? 'begin' (inline_expr_identification)? end
+ hmsc_body
+ 'loop' 'end'
+;
+
+hmsc_opt_expr:
+ 'opt' 'begin' (inline_expr_identification)? end
+ hmsc_body
+ 'opt' 'end'
+;
+
+hmsc_alt_expr:
+ 'alt' 'begin' (inline_expr_identification)? end
+ hmsc_body
+ ('alt' end hmsc_body)*
+ 'alt' 'end'
+;
+
+hmsc_seq_expr:
+ 'seq' 'begin' (inline_expr_identification)? end
+ hmsc_body
+ ('seq' end hmsc_body)*
+ 'seq' 'end'
+;
+
+hmsc_par_expr:
+ 'par' 'begin' (inline_expr_identification)? end
+ hmsc_body
+ ('par' end hmsc_body)*
+ 'par' 'end'
+;
+
+hmsc_exc_expr:
+ 'exc' 'begin' (inline_expr_identification)? end
+ hmsc_body
+ 'exc' 'end'
+;
+
+// end of file
Added: trunk/src/data/Z120/Z120.h
===================================================================
--- trunk/src/data/Z120/Z120.h (rev 0)
+++ trunk/src/data/Z120/Z120.h 2008-05-10 21:53:44 UTC (rev 68)
@@ -0,0 +1,28 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2008 Petr Gotthard <pet...@ce...>
+ *
+ * $Id: Z120.g 43 2008-04-24 12:05:24Z gotthardp $
+ */
+
+#include <string>
+
+class Z120
+{
+public:
+ virtual ~Z120() {}
+ virtual int readFile(const std::string& filename);
+};
+
+// end of file
Added: trunk/src/data/Z120/main.cpp
===================================================================
--- trunk/src/data/Z120/main.cpp (rev 0)
+++ trunk/src/data/Z120/main.cpp 2008-05-10 21:53:44 UTC (rev 68)
@@ -0,0 +1,15 @@
+#include <string>
+#include "Z120.h"
+
+int main(int argc, char *argv[])
+{
+ std::string filename = "./test.msc";
+
+ if (argc > 2 && argv[1] == NULL)
+ filename = argv[1];
+
+ Z120 reader;
+ reader.readFile( filename );
+
+ return 0;
+}
Added: trunk/src/data/Z120/test.msc
===================================================================
--- trunk/src/data/Z120/test.msc (rev 0)
+++ trunk/src/data/Z120/test.msc 2008-05-10 21:53:44 UTC (rev 68)
@@ -0,0 +1,14 @@
+msc pok2;
+A: instance;
+B: instance;
+A: in A,1 from found;
+A: out jedna,2 to B;
+B: in jedna,2 from A;
+A: concurrent;
+A: out B1,3 to B;
+B: in B1,3 from A;
+A: out B,4 to lost;
+A: endconcurrent;
+A: endinstance;
+B: endinstance;
+endmsc;
Property changes on: trunk/src/data/Z120/test.msc
___________________________________________________________________
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|