--- a/stage1_2/iec.flex Sun Oct 28 22:03:27 2007 +0100
+++ b/stage1_2/iec.flex Sun Oct 28 22:44:20 2007 +0100
@@ -335,14 +335,24 @@
* (when expecting an action qualifier. This transition is requested by bison)
* sfc_qualifier_state -> pop()
* (when no longer expecting an action qualifier. This transition is requested by bison)
- *
- */
-
+ * config_state -> push(config_state); goto(task_init_state)
+ * (when parsing a task initialisation. This transition is requested by bison)
+ * task_init_state -> pop()
+ * (when no longer parsing task initialisation parameters. This transition is requested by bison)
+ *
+ */
/* we are parsing a configuration. */
%s config_state
+/* Inside a configuration, we are parsing a task initialisation parameters */
+/* This means that PRIORITY, SINGLE and INTERVAL must be handled as
+ * tokens, and not as possible identifiers. Note that the above words
+ * are not keywords.
+ */
+%s task_init_state
+
/* we are parsing a function, program or function block declaration */
%s decl_state
@@ -680,6 +690,11 @@
rst_goto_sfc_qualifier_state();
}
+ if (get_goto_task_init_state()) {
+ yy_push_state(task_init_state);
+ rst_goto_task_init_state();
+ }
+
if (get_pop_state()) {
yy_pop_state();
rst_pop_state();
@@ -1144,12 +1159,17 @@
END_TRANSITION return END_TRANSITION;
FROM return FROM;
TO return TO;
-PRIORITY return PRIORITY;
INITIAL_STEP return INITIAL_STEP;
STEP return STEP;
END_STEP return END_STEP;
+ /* PRIORITY is not a keyword, so we only return it when
+ * it is explicitly required and we are not expecting any identifiers
+ * that could also use the same letter sequence (i.e. an identifier: piority)
+ */
+<sfc_state>PRIORITY return PRIORITY;
+
<sfc_qualifier_state>{
L return L;
D return D;
@@ -1179,12 +1199,18 @@
PROGRAM return PROGRAM;
RETAIN return RETAIN;
NON_RETAIN return NON_RETAIN;
+READ_WRITE return READ_WRITE;
+READ_ONLY return READ_ONLY;
+
+ /* PRIORITY, SINGLE and INTERVAL are not a keywords, so we only return them when
+ * it is explicitly required and we are not expecting any identifiers
+ * that could also use the same letter sequence (i.e. an identifier: piority, ...)
+ */
+<task_init_state>{
PRIORITY return PRIORITY;
SINGLE return SINGLE;
INTERVAL return INTERVAL;
-READ_WRITE return READ_WRITE;
-READ_ONLY return READ_ONLY;
-
+}
/***********************************/
/* B 2.1 Instructions and Operands */
--- a/stage1_2/iec.y Sun Oct 28 22:03:27 2007 +0100
+++ b/stage1_2/iec.y Sun Oct 28 22:44:20 2007 +0100
@@ -210,8 +210,9 @@
* after all includes have already been processed.
*
* Flex automatically returns the token with value 0
- * at the end of the file. We therefore specify
- * a token with that exact same value here.
+ * at the end of the file. We therefore specify here
+ * a token with that exact same value here, so we can use it
+ * to detect the very end of the input files.
*/
%token END_OF_INPUT 0
@@ -912,6 +913,11 @@
%type <leaf> task_configuration
%type <leaf> task_name
%type <leaf> task_initialization
+// 3 helper symbols for task_initialization
+%type <leaf> task_initialization_single
+%type <leaf> task_initialization_interval
+%type <leaf> task_initialization_priority
+
%type <leaf> data_source
%type <leaf> program_configuration
// helper symbol for program_configuration
@@ -4140,17 +4146,54 @@
*/
task_name: any_identifier;
+
task_initialization:
// '(' [SINGLE ASSIGN data_source ','] [INTERVAL ASSIGN data_source ','] PRIORITY ASSIGN integer ')' //
- '(' PRIORITY ASSIGN integer ')'
- {$$ = new task_initialization_c(NULL, NULL, $4, locloc(@$));}
-| '(' SINGLE ASSIGN data_source ',' PRIORITY ASSIGN integer ')'
- {$$ = new task_initialization_c($4, NULL, $8, locloc(@$));}
-| '(' INTERVAL ASSIGN data_source ',' PRIORITY ASSIGN integer ')'
- {$$ = new task_initialization_c(NULL, $4, $8, locloc(@$));}
-| '(' SINGLE ASSIGN data_source ',' INTERVAL ASSIGN data_source ',' PRIORITY ASSIGN integer ')'
- {$$ = new task_initialization_c($4, $8, $12, locloc(@$));}
-;
+ '(' task_initialization_single task_initialization_interval task_initialization_priority ')'
+ {$$ = new task_initialization_c($2, $3, $4, locloc(@$));}
+;
+
+
+task_initialization_single:
+// [SINGLE ASSIGN data_source ',']
+ /* empty */
+ {$$ = NULL;}
+| {cmd_goto_task_init_state();} SINGLE ASSIGN {cmd_pop_state();} data_source ','
+ {$$ = $5;}
+;
+
+
+task_initialization_interval:
+// [INTERVAL ASSIGN data_source ',']
+ /* empty */
+ {$$ = NULL;}
+| {cmd_goto_task_init_state();} INTERVAL ASSIGN {cmd_pop_state();} data_source ','
+ {$$ = $5;}
+;
+
+
+task_initialization_priority:
+// PRIORITY ASSIGN integer
+{cmd_goto_task_init_state();} PRIORITY ASSIGN {cmd_pop_state();} integer
+ {$$ = $5;}
+;
+
+
+/*
+task_initialization:
+// '(' [SINGLE ASSIGN data_source ','] [INTERVAL ASSIGN data_source ','] PRIORITY ASSIGN integer ')' //
+ '(' {cmd_goto_task_init_state();} PRIORITY ASSIGN {cmd_pop_state();} integer ')'
+ {$$ = new task_initialization_c(NULL, NULL, $6, locloc(@$));}
+| '(' {cmd_goto_task_init_state();} SINGLE ASSIGN {cmd_pop_state();} data_source ','
+ PRIORITY ASSIGN integer ')'
+ {$$ = new task_initialization_c($6, NULL, $10, locloc(@$));}
+| '(' {cmd_goto_task_init_state();} INTERVAL ASSIGN {cmd_pop_state();} data_source ',' PRIORITY ASSIGN integer ')'
+ {$$ = new task_initialization_c(NULL, $6, $10, locloc(@$));}
+| '(' {cmd_goto_task_init_state();} SINGLE ASSIGN {cmd_pop_state();} data_source ',' INTERVAL ASSIGN data_source ',' PRIORITY ASSIGN integer ')'
+ {$$ = new task_initialization_c($6, $10, $14, locloc(@$));}
+;
+*/
+
data_source:
constant
--- a/stage1_2/stage1_2.cc Sun Oct 28 22:03:27 2007 +0100
+++ b/stage1_2/stage1_2.cc Sun Oct 28 22:44:20 2007 +0100
@@ -75,6 +75,14 @@
int get_goto_sfc_qualifier_state(void) {return goto_sfc_qualifier_state__;}
void rst_goto_sfc_qualifier_state(void) {goto_sfc_qualifier_state__ = 0;}
+/*************************************************************/
+/* Controlling the entry to the sfc_qualifier_state in flex. */
+/*************************************************************/
+static int goto_task_init_state__ = 0;
+
+void cmd_goto_task_init_state(void) {goto_task_init_state__ = 1;}
+int get_goto_task_init_state(void) {return goto_task_init_state__;}
+void rst_goto_task_init_state(void) {goto_task_init_state__ = 0;}
/****************************************************************/
/* Returning to state in flex previously pushed onto the stack. */
--- a/stage1_2/stage1_2_priv.hh Sun Oct 28 22:03:27 2007 +0100
+++ b/stage1_2/stage1_2_priv.hh Sun Oct 28 22:44:20 2007 +0100
@@ -99,6 +99,14 @@
void rst_goto_sfc_qualifier_state(void);
+/*********************************************************/
+/* Controlling the entry to the task_init_state in flex. */
+/*********************************************************/
+void cmd_goto_task_init_state(void);
+int get_goto_task_init_state(void);
+void rst_goto_task_init_state(void);
+
+
/****************************************************************/
/* Returning to state in flex previously pushed onto the stack. */
/****************************************************************/