diff -r 2d50e7e2a2bd lib/string/abstract_string.li --- a/lib/string/abstract_string.li Sun Aug 31 01:37:20 2008 +0200 +++ b/lib/string/abstract_string.li Sun Aug 31 11:43:29 2008 +0200 @@ -271,7 +271,18 @@ - has_substring other:ABSTRACT_STRING :BOOLEAN <- // True if `other' is in the STRING. ( first_substring_index other != 0 ); - + + - occurrences_string s:ABSTRACT_STRING :INTEGER <- + // Number of times character `c' appears in the string. + ( + n, i :INTEGER; + i := first_substring_index s; + { i != 0 }.while_do { + n := n + 1; + i := substring_index (s, i); + }; + n + ); + - occurrences c:CHARACTER :INTEGER <- // Number of times character `c' appears in the string. ( diff -r 2d50e7e2a2bd src/parser.li --- a/src/parser.li Sun Aug 31 01:37:20 2008 +0200 +++ b/src/parser.li Sun Aug 31 11:43:29 2008 +0200 @@ -487,7 +487,7 @@ result ); - //-- cap_identifier -> 'A'-'Z' {'A'-'Z' | '0'-'9' | '_'} + //-- cap_identifier -> 'A'-'Z' {'A'-'Z' | '0'-'9' | '_' | ':'} - read_cap_identifier:BOOLEAN <- ( + posold,idx:INTEGER; + result:BOOLEAN; @@ -502,7 +502,8 @@ { (! last_character.is_upper) && {! last_character.is_digit} && - {last_character != '_'} + {last_character != '_'} && + {last_character != ':'} } }.until_do { string_tmp.add_last last_character; @@ -510,9 +511,22 @@ }; (! string_tmp.is_empty).if { idx := string_tmp.first_substring_index "__"; - (idx != 0).if { + (idx != 0).if { position := posold + idx; - syntax_error (current_position,"Identifier is incorrect."); + syntax_error (current_position,"Identifier is incorrect (__ is not allowed)."); + }; + idx := string_tmp.first_substring_index ":::"; + (idx != 0).if { + position := posold + idx; + syntax_error (current_position,"Identifier is incorrect (::: is not allowed)."); + }; + (string_tmp.last = ':').if { + position := posold + string_tmp.count; + syntax_error (current_position,"Identifier is incorrect (: is not allowed at the very end)."); + }; + (sring_tmp.occurrences_string "" > 1).if { + position := posold; + syntax_error (current_position,"Identifier is incorrect (:: is allowed only once)."); }; last_string := ALIAS_STR.get string_tmp; result := TRUE;