633 /***** *****/ |
633 /***** *****/ |
634 /*****************************************************/ |
634 /*****************************************************/ |
635 /*****************************************************/ |
635 /*****************************************************/ |
636 /*****************************************************/ |
636 /*****************************************************/ |
637 |
637 |
638 if (goto_body_state__) { |
638 if (get_goto_body_state()) { |
639 yy_push_state(il_st_state); |
639 yy_push_state(il_st_state); |
640 goto_body_state__ = 0; |
640 rst_goto_body_state(); |
641 } |
641 } |
642 |
642 |
643 /*********************************/ |
643 /*********************************/ |
644 /* Handle the pragmas! */ |
644 /* Handle the pragmas! */ |
645 /*********************************/ |
645 /*********************************/ |
646 |
646 |
647 /* We start off by searching for the pragmas we handle in the lexical parser. */ |
647 /* We start off by searching for the pragmas we handle in the lexical parser. */ |
648 <INITIAL>{file_include_pragma} unput_text(0); yy_push_state(include_beg); |
648 <INITIAL>{file_include_pragma} unput_text(0); yy_push_state(include_beg); |
649 |
649 |
650 /* Any other pragma we find, we just pass it up to the syntax parser... */ |
650 /* Any other pragma we find, we just pass it up to the syntax parser... */ |
651 /* Note that the <body> state is exclusive, so we have to include it here too. */ |
651 /* Note that the <il_st_state> state is exclusive, so we have to include it here too. */ |
652 {pragma} {/* return the pragmma without the enclosing '{' and '}' */ |
652 {pragma} {/* return the pragmma without the enclosing '{' and '}' */ |
653 yytext[strlen(yytext)-2] = '\0'; |
653 yytext[strlen(yytext)-1] = '\0'; |
654 yylval.ID=strdup(yytext+1); |
654 yylval.ID=strdup(yytext+1); |
655 return pragma_token; |
655 return pragma_token; |
656 } |
656 } |
657 <il_st_state>{pragma} {/* return the pragmma without the enclosing '{' and '}' */ |
657 <il_st_state>{pragma} {/* return the pragmma without the enclosing '{' and '}' */ |
658 yytext[strlen(yytext)-2] = '\0'; |
658 yytext[strlen(yytext)-1] = '\0'; |
659 yylval.ID=strdup(yytext+1); |
659 yylval.ID=strdup(yytext+1); |
660 return pragma_token; |
660 return pragma_token; |
661 } |
661 } |
662 |
662 |
663 |
663 |
784 } |
784 } |
785 } |
785 } |
786 |
786 |
787 /* il_st_state -> (il_state | st_state) */ |
787 /* il_st_state -> (il_state | st_state) */ |
788 <il_st_state>{ |
788 <il_st_state>{ |
|
789 {st_whitespace_no_pragma} /* Eat any whitespace */ |
789 {qualified_identifier}{st_whitespace}":=" unput_text(0); BEGIN(st_state); |
790 {qualified_identifier}{st_whitespace}":=" unput_text(0); BEGIN(st_state); |
790 {qualified_identifier}"[" unput_text(0); BEGIN(st_state); |
791 {qualified_identifier}"[" unput_text(0); BEGIN(st_state); |
791 |
792 |
792 RETURN unput_text(0); BEGIN(st_state); |
793 RETURN unput_text(0); BEGIN(st_state); |
793 IF unput_text(0); BEGIN(st_state); |
794 IF unput_text(0); BEGIN(st_state); |
843 /***************************************/ |
843 /***************************************/ |
844 /* Next is to to remove all whitespace */ |
844 /* Next is to to remove all whitespace */ |
845 /***************************************/ |
845 /***************************************/ |
846 /* NOTE: pragmas are handled right at the beginning... */ |
846 /* NOTE: pragmas are handled right at the beginning... */ |
847 |
847 |
848 <INITIAL,config_state,decl_state,st_state,sfc_state,il_st_state>{st_whitespace_no_pragma} /* Eat any whitespace */ |
848 <INITIAL,config_state,decl_state,st_state,sfc_state>{st_whitespace_no_pragma} /* Eat any whitespace */ |
849 <il_state,il_st_state>{il_whitespace_no_pragma} /* Eat any whitespace */ |
849 <il_state>{il_whitespace_no_pragma} /* Eat any whitespace */ |
850 |
850 |
851 |
851 |
852 /*****************************************/ |
852 /*****************************************/ |
853 /* B.1.1 Letters, digits and identifiers */ |
853 /* B.1.1 Letters, digits and identifiers */ |
854 /*****************************************/ |
854 /*****************************************/ |
863 * |
863 * |
864 * That is why the first thing we do with identifiers, even before |
864 * That is why the first thing we do with identifiers, even before |
865 * checking whether they may be a 'keyword', is to check whether |
865 * checking whether they may be a 'keyword', is to check whether |
866 * they have been previously declared as a variable name, |
866 * they have been previously declared as a variable name, |
867 * |
867 * |
868 * TODO: how about function names? |
868 * However, we have a dilema! Should we here also check for |
|
869 * prev_declared_derived_function_name_token? |
|
870 * If we do, then the 'MOD' default library function (defined in |
|
871 * the standard) will always be returned as a function name, and |
|
872 * it will therefore not be possible to use it as an operator as |
|
873 * in the following ST expression 'X := Y MOD Z;' ! |
|
874 * If we don't, then even it will not be possible to use 'MOD' |
|
875 * as a funtion as in 'X := MOD(Y, Z);' |
|
876 * We solve this by NOT testing for function names here, and |
|
877 * handling this function and keyword clash in bison! |
869 */ |
878 */ |
870 {identifier} {int token = get_identifier_token(yytext); |
879 {identifier} {int token = get_identifier_token(yytext); |
871 if ((token == prev_declared_variable_name_token) || |
880 if ((token == prev_declared_variable_name_token) || |
|
881 // (token == prev_declared_derived_function_name_token) || // DO NOT add this condition! |
872 (token == prev_declared_fb_name_token)) { |
882 (token == prev_declared_fb_name_token)) { |
873 /* |
883 /* |
874 if (token != identifier_token) |
884 if (token != identifier_token) |
875 */ |
885 */ |
876 /* NOTE: if we use the above line, then 'MOD' et al must be removed |
886 /* NOTE: if we replace the above uncommented conditions with |
877 * from the library_symbol_table as a default function name! |
887 * the simple test of (token != identifier_token), then |
|
888 * 'MOD' et al must be removed from the |
|
889 * library_symbol_table as a default function name! |
878 */ |
890 */ |
879 yylval.ID=strdup(yytext); |
891 yylval.ID=strdup(yytext); |
880 return token; |
892 return token; |
881 } |
893 } |
882 /* otherwise, leave it for the other lexical parser rules... */ |
894 /* otherwise, leave it for the other lexical parser rules... */ |