REXX ANSI Reference Syntax - adesutherland/CREXX GitHub Wiki

REXX ANSI Reference (Syntax)

This are extracted requirements from the ANSI specification used to cross reference and validate compliance. Some bullets and paragraphs have been converted to numbered lists to aid referencing.

ANSI Ref CREXX Ref Specification
6.2 Lexical The lexical level processes the source and provides tokens for further recognition by the top syntax level
6.2.1 Lexical elements
6.2.1.1 Events The fully capitalized identifiers in the BNF syntax (see section 6.2.2) represent events. An event is either supplied by the configuration or occurs as result of a look-ahead in left-to-right parsing. The following events are defined:
6.2.1.1.1 - EOL occurs at the end of a line of the source. It is provided by Config_SourceChar, see section 5.4.1.
6.2.1.1.2 eos - EOS occurs at the end of the source. It is provided by Config_SourceChar.
6.2.1.1.3 - RADIX occurs when the character about to be scanned is 'X' or 'x' or 'B' or 'b' not followed by a general_letter, or a digit, or '.'.
6.2.1.1.4 - CONTINUE occurs when the character about to be scanned is ',', and the characters after the ',' up to EOL represent a repetition of comment or blank, and the EOL is not immediately followed by an EOS.
6.2.1.1.5 - EXPONENT_SIGN occurs when the character about to be scanned is '+' or '-', and the characters to the left of the sign, currently parsed as part of Const_symbol, represent a plain_number followed by 'E' or 'e', and the characters to the right of the sign represent a repetition of digit not followed by a general_letter or '.'.
6.2.1.2 Actions and tokens Mixed case identifiers with an initial capital letter cause an action when they appear as operands in a production. These actions perform further tests and create tokens for use by the top syntax level. The following actions are defined:
6.2.1.2.1 - Special supplies the source recognized as special to the top syntax level.
6.2.1.2.2 - Eol supplies a semicolon to the top syntax level.
6.2.1.2.3 - Eos supplies an end of source indication to the top syntax level.
6.2.1.2.4 - Var_symbol supplies the source recognized as Var_symbol to the top syntax level, as keywords or VAR_SYMBOL tokens, see section 6.2.3. The characters in a Var_symbol are converted by Config_Upper to uppercase. Msg30.1 shall be produced if Var_symbol contains more than #Limit_Name characters, see section 5.10.1.
6.2.1.2.5 - Const_symbol supplies the source recognized as Const_symbol to the top syntax level. If it is a number it is passed as a NUMBER token, otherwise it is passed as a CONST_SYMBOL token. The characters in a Const_symbol are converted by Config_Upper to become the characters that comprise that NUMBER or CONST_SYMBOL. Msg30.1 shall be produced if Const_symbol contains more than #Limit_Name characters.
6.2.1.2.6 - Embedded_quotation_mark records an occurrence of two consecutive quotation marks within a string delimited by quotation marks for further processing by the String action.31
6.2.1.2.7 - Embedded_apostrophe records an occurrence of two consecutive apostrophes within a string delimited by apostrophes for further processing by the String action.
6.2.1.2.8 - String supplies the source recognized as String to the top syntax level as a STRING token. Any occurrence of Embedded_quotation_mark or Embedded_apostrophe is replaced by a single quotation mark or apostrophe, respectively. Msg30.2 shall be produced if the resulting string contains more than #Limit_Literal characters.
6.2.1.2.9 - Binary_string supplies the converted binary string to the top syntax level as a STRING token, after checking conformance to the binary_string syntax. If the binary_string does not contain any occurrence of a binary_digit a string of length 0 is passed to the top syntax level. The occurrences of binary_digit are concatenated to form a number in radix 2. Zero digits are added at the left if necessary to make the number of digits a multiple of 8. If the resulting number of digits exceeds 8 times #Limit_Literal then Msg30.2 shall be produced. The binary digits are converted to an encoding, see section 5.4.5. The encoding is supplied to the top syntax level as a STRING token.
6.2.1.2.10 - Hex_string supplies the converted hexadecimal string to the top syntax level as a STRING token, after checking conformance to the hex_string syntax. If the hex_string does not contain any occurrence of a hex_digit a string of length 0 is passed to the top syntax level. The occurrences of hex_digit are each converted to a number with four binary digits and concatenated. Zero digits are added at the left if necessary to make the number of digits a multiple of 8. If the resulting number of digits exceeds 8 times #Limit_Literal then Msg30.2 shall be produced. The binary digits are converted to an encoding. The encoding is supplied to the top syntax level as a STRING token.
6.2.1.2.11 - Operator supplies the source recognized as Operator (excluding characters that are not operator_char ) to the top syntax level. Any occurrence of an other_negator within Operator is supplied as ''.
6.2.1.2.12 - Blank records the presence of a blank in the following token. This may subsequently be tested (see section 6.2.3).
6.2.1.2.13 Constructions of type Number, Const_symbol, Var_symbol or String are called operands.
6.2.1.3 Source characters
6.2.1.3.1 The source is obtained from the configuration by the use of Config_SourceChar (see section 5.4.1). If no character is available because the source is not a correct encoding of characters, message Msg22.1 shall be produced.
6.2.1.3.2 The terms extra_letter, other_blank_character, other_negator, and other_character used in the productions of the lexical level refer to characters of the groups extra_letters (see section 5.3.2), other_blank_characters (see section 5.3.3), other_negators (see section 5.3.4) and other_characters (see section 5.3.5), respectively.
6.2.1.4 Rules In scanning, recognition that causes an action (see section 6.2.1.2) only occurs if no other recognition is possible
6.2.2 Lexical level
6.2.2.1 digit := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
6.2.2.2 special := ',' | ':' | ';' | ')' | '('
6.2.2.3 not := '' | other_negator
6.2.2.4 operator_only := '+' | '-' | '%' | '
6.2.2.5 operator_or_other := '/' | '*'
6.2.2.6 operator_char := operator_only | operator_or_other
6.2.2.7 general_letter := '_' | '!' | '?' | extra_letter | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'
6.2.2.8 blank := ' ' | other_blank_character
6.2.2.9 bo := [blank+]
6.2.2.10 string_or_comment_char := digit | '.' | special | operator_only | general_letter | blank | other_character
6.2.2.11 tokenize := [between+] [tokenbetween+] EOS Eos
6.2.2.12 tokenbetween := token [between+]
6.2.2.13 token := operand | Operator | Special
6.2.2.14 operand := string_literal | Var_symbol | Const_symbol
6.2.2.15 between := comment | blank_run Blank | EOL Eol | Msg13.1
6.2.2.16 blank_run := (blank | continuation)+
6.2.2.17 continuation := CONTINUE ',' [(comment | blank)+] EOL
6.2.2.18 comment := '/' '*' [commentpart+] ['*'+] ('*' '/' | EOS Msg6.1)
6.2.2.19 commentpart := comment | ['/'+] comment_char+ | '*'+ comment_char+
6.2.2.20 comment_char := string_or_comment_char | '"' | "'" | EOL
6.2.2.21 string_literal := Hex_string | Binary_string | String
6.2.2.22 String := quoted_string
6.2.2.23 Hex_string := quoted_string RADIX ('x' | 'X')
6.2.2.24 Binary_string := quoted_string RADIX ('b' | 'B')
6.2.2.25 quoted_string := quotation_mark_string [(Embedded_quotation_mark quotation_mark_string)+] |
6.2.2.26 quotation_mark_string := '"' [(string_char | "'")+] ('"' | EOL Msg6.3)
6.2.2.27 apostrophe_string := "'" [(string_char | '"')+] ("'" | EOL Msg6.2)
6.2.2.28 string_char := string_or_comment_char | '*' | '/'
6.2.2.29 Var_symbol := general_letter [var_symbol_char+]
6.2.2.30 var_symbol_char := general_letter | digit | '.'
6.2.2.31 Const_symbol := (digit | '.') [const_symbol_char+]
6.2.2.32 const_symbol_char := var_symbol_char | EXPONENT_SIGN ('+' | '-')
6.2.2.33 Special := special
6.2.2.34 Operator := operator_char | '
6.2.2.35 number := plain_number [exponent]
6.2.2.36 plain_number := ['.'] digit+ | digit+ '.' [digit+]
6.2.2.37 exponent := ('e' | 'E') ['+' | '-'] digit+
6.2.2.38 hex_string := (hex_digit [break_hex_digit_pair+] | [hex_digit hex_digit [break_hex_digit_pair+]]) | (Msg15.1 | Msg15.3)
6.2.2.39 hex_digit := digit | 'a' | 'A' | 'b' | 'B' | 'c' | 'C' | 'd' | 'D' | 'e' | 'E' | 'f' | 'F'
6.2.2.40 break_hex_digit_pair := bo hex_digit hex_digit
6.2.2.41 binary_string := (binary_digit [break_binary_digit_quad+] | binary_digit binary_digit [break_binary_digit_quad+] | binary_digit binary_digit binary_digit [break_binary_digit_quad+] | [binary_digit binary_digit binary_digit binary_digit [break_binary_digit_quad+]]) | (Msg15.2 | Msg15.4)
6.2.2.42 binary_digit := '0' | '1'
6.2.2.43 break_binary_digit_quad := bo binary_digit binary_digit binary_digit binary_digit
6.2.3 Interaction between levels of syntax
6.2.3.0.1 When the lexical process recognizes tokens to be supplied to the top level, there can be changes made or tokens added. Recognition is performed by the lexical process and the top level process in a synchronized way. The tokens produced by the lexical level can be affected by what the top level syntax has recognized. Those tokens will affect subsequent recognition by the top level. Both processes operate on the characters and the tokens in the order they are produced. The term "context" refers to the progress of the recognition at some point, without consideration of unprocessed characters and tokens.
6.2.3.0.2 If a token which is '+', '—', '' or '(' appears in a lexical level context (other than after the keyword 'PARSE') where the keyword 'VALUE' could appear in the corresponding top level context, then 'VALUE' is passed to the top level before the token is passed.
6.2.3.0.3 If an '=' operator_char appears in a lexical level context where it could be the '=' of an assignment in the corresponding top level context then theVar_symbolpreceding it is passed as a VAR_SYMBOL. If an operand is followed by a colon token in the lexical level context then the operand only is passed to the top level syntax as a LABEL, provided the context permits a LABEL.
6.2.3.0.4 Except where the rules above determine the token passed, a Var_symbol is passed as a terminal (a keyword) rather than as a VAR_SYMBOL under the following circumstances:
6.2.3.0.5 – If the symbol is spelled 'WHILE' or 'UNTIL' it is a keyword wherever a VAR_SYMBOL would be part of an expression within a do_specification.
6.2.3.0.6 – If the symbol is spelled 'TO' , 'BY', or 'FOR' it is a keyword wherever a VAR_SYMBOL would be part of an expression within a do_rep.
6.2.3.0.7 – If the symbol is spelled 'WITH' it is a keyword wherever a VAR_SYMBOL would be part of a parsevalue, or part of an expression or taken_constant within address.
6.2.3.0.8 – If the symbol is spelled 'THEN' it is keyword wherever a VAR_SYMBOL would be part of an expression immediately following the keyword 'IF' or 'WHEN'.
6.2.3.0.9 Except where the rules above determine the token passed, a Var_symbol is passed as a keyword if the spelling of it matches a keyword which the top level syntax recognizes in its current context, otherwise the Var_symbol is passed as a VAR_SYMBOL token.
6.2.3.0.10 When a Var_symbol is passed as a terminal because of the spelling match it is referred to as a keyword.
6.2.3.0.11 In a context where the top level syntax could accept a '||' token as the next token, a '||' operator or a ' ' operator may be inferred and passed to the top level provided that the next token from the lexical level is a left parenthesis or an operand that is not a keyword. If the blank action has recorded the presence of one or more blanks to the left of the next token then the ' ' operator is inferred. Otherwise, a '||' operator is inferred, except if the next token is a left parenthesis following an operand; in this case no operator is inferred.
6.2.3.0.12 When any of the keywords 'OTHERWISE', 'THEN', or 'ELSE' is recognized, a semicolon token is supplied as the following token. A semicolon token is supplied as the previous token when the 'THEN' keyword is recognized. A semicolon token is supplied as the token following a LABEL.
6.2.3.1 Reserved symbols A Const_symbol which starts with a period and is not a Number shall be spelled .MN, .RESULT, .RC, .RS, or .SIGL otherwise Msg50.1 is issued.
6.2.3.2 Function name syntax A symbol which is the leftmost component of a function shall not end with a period, otherwise Msg51.1 is issued.
6.3 Syntax
6.3.1 Syntax elements The tokens generated by the actions described in section 6.2.1 form the basis for recognizing larger constructs.
6.3.2 Syntax level
6.3.2.1 /* The first part introduces the overall structure of a program */
program := [ncl] [instruction_list] ['END' Msg10.1]
6.3.2.2 ncl := null_clause+ | Msg21.1
6.3.2.3 null_clause := ';' [label_list]
6.3.2.4 label_list := (LABEL ';')+
6.3.2.5 instruction_list:= instruction+
6.3.2.6 instruction := group | single_instruction ncl
6.3.2.7 single_instruction:= assignment | keyword_instruction | command
6.3.2.8 assignment := VAR_SYMBOL '=' expression | NUMBER '=' Msg31.1 | CONST_SYMBOL '=' (Msg31.2 | Msg31.3)
6.3.2.9 keyword_instruction:= address | arg | call | drop | exit | interpret | iterate | leave | nop | numeric | options | parse | procedure | pull | push | queue | return | say | signal | trace | 'THEN' Msg8.1 | 'ELSE' Msg8.2 | 'WHEN' Msg9.1 | 'OTHERWISE' Msg9.2
6.3.2.10 command := expression
6.3.2.11 group := do | if | select
6.3.2.12 do := do_specification (ncl | Msg21.1 | Msg27.1) [instruction_list] do_ending
6.3.2.13 do_ending := 'END' [VAR_SYMBOL] ncl | EOS Msg14.1 | Msg35.1
6.3.2.14 if := 'IF' expression [ncl] (then | Msg18.1) [else]
6.3.2.15 then := 'THEN' ncl (instruction | EOS Msg14.3 | 'END' Msg105)
6.3.2.16 else := 'ELSE' ncl (instruction | EOS Msg14.4 | 'END' Msg10.6)
6.3.2.17 select := 'SELECT' ncl select_body ('END' [VAR_SYMBOL Msg10.4] ncl | EOS Msg14.2 | Msg7.2)
6.3.2.18 select_body := (when | Msg7.1) [when+] [otherwise]
6.3.2.19 when := 'WHEN' expression [ncl] (then | Msg18.2)
6.3.2.20 otherwise := 'OTHERWISE' ncl [instruction_list]
6.3.2.21 /* Note: The next part concentrates on the instructions. It leaves unspecified the various forms of symbol, template and expression. */
address := 'ADDRESS' [(taken_constant [expression] | Msg19.1 | valueexp) [ 'WITH' connection]]
6.3.2.22 taken_constant := symbol | STRING
6.3.2.23 valueexp := 'VALUE' expression
6.3.2.24 connection := error [adio] | input [adeo] | output [adei] | Msg25.5
6.3.2.25 adio := input [output] | output [input]
6.3.2.26 input := 'INPUT' (resourcei | Msg25.6)
6.3.2.27 resourcei := resources | 'NORMAL'
6.3.2.28 output := 'OUTPUT' (resourceo | Msg25.7)
6.3.2.29 resourceo := 'APPEND' (resources | Msg25.8) | 'REPLACE' (resources | Msg25.9) | resources | 'NORMAL'
6.3.2.30 adeo := error [output] | output [error]
6.3.2.31 error := 'ERROR' (resourceo | Msg25.14)
6.3.2.32 adei := error [input] | input [error]
6.3.2.33 resources := 'STREAM' (VAR_SYMBOL | Msg53.1) | 'STEM' (VAR_SYMBOL | Msg53.2)
6.3.2.34 vref := '(' var_symbol (')' | Msg46.1)
6.3.2.35 var_symbol := VAR_SYMBOL | Msg20.1
6.3.2.36 arg := 'ARG' [template_list]
6.3.2.37 call := 'CALL' (callon_spec| (taken_constant|Msg19.2)[expression_list])
6.3.2.38 callon_spec := 'ON' (callable_condition | Msg25.1) ['NAME' (taken_constant | Msg19.3)] | 'OFF' (callable_condition | Msg25.2)
6.3.2.39 callable_condition:= 'ERROR' | 'FAILURE' | 'HALT' | 'NOTREADY'
6.3.2.40 expression_list := expr | [expr] ',' [expression_list]
6.3.2.41 do_specification := do_simple | do_repetitive
6.3.2.41 do_simple := 'DO'
6.3.2.43 do_repetitive := 'DO' dorep | 'DO' docond | 'DO' dorep docond | 'DO' 'FOREVER' [docond | Msg25.16]
6.3.2.44 docond := 'WHILE' whileexpr | 'UNTIL' untilexpr
6.3.2.45 untilexpr := expression
6.3.2.46 whileexpr := expression
6.3.2.47 dorep := assignment [docount] | repexpr
6.3.2.48 repexpr := expression
6.3.2.49 docount := dot [dobf] | dob [dotf] | dof [dotb]
6.3.2.50 dobf := dob [dof] | dof [dob]
6.3.2.51 dotf := dot [dof] | dof [dot]
6.3.2.52 dotb := dot [dob] | dob [dot]
6.3.2.53 dot := 'TO' toexpr
6.3.2.54 toexpr := expression
6.3.2.55 dob := 'BY' byexpr
6.3.2.56 byexpr := expression
6.3.2.57 dof := 'FOR' forexpr
6.3.2.58 forexpr := expression
6.3.2.59 drop := 'DROP' variable_list
6.3.2.60 variable_list := (vref | var_symbol)+
6.3.2.61 exit := 'EXIT' [expression]
6.3.2.62 interpret := 'INTERPRET' expression
6.3.2.63 iterate := 'ITERATE' [VAR_SYMBOL | Msg20.2 ]
6.3.2.64 leave := 'LEAVE' [VAR_SYMBOL | Msg20.2 ]
6.3.2.65 nop := 'NOP'
6.3.2.66 numeric := 'NUMERIC' (numeric_digits | numeric_form | numeric_fuzz | Msg25.15)
6.3.2.67 numeric_digits := 'DIGITS' [expression]
6.3.2.68 numeric_form := 'FORM' ('ENGINEERING' | 'SCIENTIFIC' | valueexp | Msg25.11)
6.3.2.69 numeric_fuzz := 'FUZZ' [expression]
6.3.2.70 options := 'OPTIONS' expression
6.3.2.71 parse := 'PARSE'(parse_type | Msg25.12)[template_list] | 'PARSE' 'UPPER' (parse_type | Msg25.13) [template_list]
6.3.2.72 parse_type := parse_key | parse_value | parse_var
6.3.2.73 parse_key := 'ARG' | 'PULL' | 'SOURCE' | 'LINEIN' | 'VERSION'
6.3.2.74 parse_value := 'VALUE' [expression] ('WITH' | Msg38.3)
6.3.2.75 parse_var := 'VAR' var_symbol
6.3.2.76 procedure := 'PROCEDURE' ['EXPOSE' variable_list | Msg25.17]
6.3.2.77 pull := 'PULL' [template_list]
6.3.2.78 push := 'PUSH' [expression]
6.3.2.79 queue := 'QUEUE' [expression]
6.3.2.80 return := 'RETURN' [expression]
6.3.2.81 say := 'SAY' [expression]
6.3.2.82 signal := 'SIGNAL' (signal_spec | valueexp | taken_constant | Msg19.4)
6.3.2.83 signal_spec := 'ON' (condition | Msg25.3) ['NAME' (taken_constant | Msg19.3)] | 'OFF' (condition | Msg25.4)
6.3.2.84 condition := callable_condition | 'NOVALUE' | 'SYNTAX' | 'LOSTDIGITS'
6.3.2.85 trace := 'TRACE' [(taken_constant | Msg19.6) | valueexp]
6.3.2.86 /* Note: The next section describes templates. */
template_list := template | [template] ',' [template_list]
6.3.2.87 template := (trigger | target | Msg38.1)+
6.3.2.88 target := VAR_SYMBOL | '.'
6.3.2.89 trigger := pattern | positional
6.3.2.90 pattern := STRING | vrefp
6.3.2.91 vrefp := '(' (VAR_SYMBOL | Msg19.7) (')' | Msg46.1)
6.3.2.92 positional := absolute_positional | relative_positional
6.3.2.93 absolute_positional:= NUMBER | '=' position
6.3.2.94 position := NUMBER | vrefp | Msg38.2
6.3.2.95 relative_positional:= ('+' | '-') position
6.3.2.96 /* Note: The final part specifies the various forms of symbol, and expression. */
symbol := VAR_SYMBOL | CONST_SYMBOL | NUMBER
6.3.2.97 expression := expr [(',' Msg37.1) | (')' Msg37.2 )]
6.3.2.98 expr := expr_alias
6.3.2.99 expr_alias := and_expression | expr_alias or_operator and_expression
6.3.2.100 or_operator := '|' | '&&'
6.3.2.101 and_expression := comparison | and_expression '&' comparison
6.3.2.102 comparison := concatenation | comparison comparison_operator concatenation
6.3.2.103 comparison_operator:= normal_compare | strict_compare
6.3.2.104 normal_compare:= '=' | '=' | '<>' | '><' | '>' | '<' | '>=' | '<=' | '>' | '<'
6.3.2.105 strict_compare:= '==' | '==' | '>>' | '<<' | '>>=' | '<<=' | '>>' | '<<'
6.3.2.106 concatenation := addition | concatenation (' ' | '||') addition
6.3.2.107 addition := multiplication | addition additive_operator multiplication
6.3.2.108 additive_operator:= '+' | '-'
6.3.2.109 multiplication := power_expression | multiplication multiplicative_operator power_expression
6.3.2.110 multiplicative_operator:= '*' | '/' | '//' | '%'
6.3.2.111 power_expression := prefix_expression | power_expression '**' prefix_expression
6.3.2.112 prefix_expression := ('+' | '-' | '') prefix_expression | term | Msg35.1
6.3.2.113 term := symbol | STRING | function | '(' expr_alias (',' Msg37.1 | ')' | Msg36)
6.3.2.114 function := taken_constant '(' [expression_list] (')' | Msg36)
6.4 Syntactic information
6.4.1 VAR_SYMBOL matching
6.4.1.1 Any VAR_SYMBOL in a do_ending must be matched by the same VAR_SYMBOL occurring at the start of an assignment contained in the do_specification of the do that contains both the do_specification and the do_ending, as described in section 6.3.2.13.
6.4.1.2 If there is a VAR_SYMBOL in a do_ending for which there is no assignment in the corresponding do_specification then message Msg10.3 is produced and no further activity is defined.
6.4.1.3 If there is a VAR_SYMBOL in a do_ending for which does not match the one occurring in the assignment then message Msg10.2 is produced and no further activity is defined.
6.4.1.4 An iterate or leave must be contained in the instruction_list of some do with a do_specification which is do_repetitive, otherwise a message (Msg28.2 or Msg28.1 respectively) is produced and no further activity is defined. If an iterate or leave contains a VAR_SYMBOL there must be a matching VAR_SYMBOL in a do_specification, otherwise a message (Msg28.1, Msg28.2, Msg28.3 or Msg28.4 appropriately) is produced and no further activity is defined. The matching VAR_SYMBOL will occur at the start of an assignment in the do_specification. The do_specification will be associated with a do by section 6.3.2.13. The iterate or leave will be a single instruction in an instruction_list associated with a do by section 6.3.2.13. These two dos shall be the same, or the latter nested one or more levels within the former. The number of levels is called the nesting_correction and influences the semantics of the iterate or leave. It is zero if the two dos are the same. The nesting_correction for iterates or leaves that do not contain VAR_SYMBOL is zero.
6.4.2 Trace-only labels Instances of LABEL which occur within a grouping_instruction and are not in a ncl at the end of that grouping_instruction are instances of trace-only labels.
6.4.3 Clauses and line numbers
6.4.3.1 The activity of tracing execution is defined in terms of clauses. A program consists of clauses, each clause ended by a semicolon special token. The semicolon may be explicit in the program or inferred.
6.4.3.2 The line number of a clause is one more than the number of EOL events recognized before the first token of the clause was recognized.
6.4.4 Nested IF instructions The syntax specification 6.3.2 allows ifs to be nested and does not fully specify the association of an else with an if. An else associates with the closest prior if that it can associate with in conformance with the syntax.
6.4.5 Choice of messages The specifications 6.2.2 and 6.3.2 permit two alternative messages in some circumstances. The following rules apply:
6.4.5.1 – Msg15.1 shall be preferred to Msg15.3 if the choice of Msg15.3 would result in the replacement for the insertion being a blank character.
6.4.5.2 – Msg15.2 shall be preferred to Msg15.4 if the choice of Msg15.4 would result in the replacement for the insertion being a blank character.
6.4.5.3 – Msg31.3 shall be preferred to Msg31.2 if the replacement for the insertion in the message starts with a period.
6.4.5.4 – Preference is given to the message that appears later in the list: Msg21.1, Msg27.1, Msg25.16, Msg36, Msg38.3, Msg35.1, other messages.
6.4.6 Creation of messages
6.4.6.0.1 The message_identifiers in section 6 correlate with the tails of stem #ErrorText., which is initialized in section 8.2.1 to identify particular messages. The action of producing an error message will replace any insertions in the message text and present the resulting text, together with information on the origin of the error, to the configuration by writing on the default error stream.
6.4.6.0.2 Further activity by the language processor is permitted, but not defined by this standard.
6.4.6.0.3 The effect of an error during the writing of an error message is not defined.
6.4.6.1 Error message prefix
6.4.6.1.1 The error message selected by the message number is preceded by a prefix. The text of the prefix is #ErrorText.0.1 except when the error is in source that execution of an interpret instruction (see section 8.3.10) is processing, in which case the text is #ErrorText.0.2. The insert called in these texts is the message number. The insert called is the line number of the error.
6.4.6.1.2 The line number of the error is one more than the number of EOL events encountered before the error was detectable, except for messages Msg6.1, Msg14, Msg14.1, Msg14.2, Msg14.3, and Msg14.4. For Msg6.1 it is one more than the number of EOL events encountered before the line containing the unmatched '/*'. For the others, it is the line number of the clause containing the keyword referenced in the message text.
6.4.6.1.3 The insert called is the value provided on the API_Start function which started processing of the program, see section 5.2.1.
6.4.6.2 Replacement of insertions Within the text of error messages, an insertion consists of the characters '<', '>', and what is between those characters. There will be a word in the insertion that specifies the replacement text, with the following meaning:
6.4.6.2.1 – If the word is 'hex-encoding' and the message is not Msg23.1 then the replacement text is the value of the leftmost character which caused the source to be syntactically incorrect. The value is in hexadecimal notation.
6.4.6.2.2 – If the word is 'token' then the replacement text is the part of the source program which was recognized as the detection token, or in the case of Msg31.1 and Msg31.2, the token before the detection token, or in the case of Msg10.2 the VAR_SYMBOL of a do_specification. The detection token is the leftmost token for which the program up to and including the token could not be parsed as the left part of a program without causing a message. If the detection token is a semicolon that was not present in the source but was supplied during recognition then the replacement is the text "end-of-line" without quotation marks.
6.4.6.2.3 – If the word is 'position' then the replacement text is a number identifying the detection character. The detection character is the leftmost character in the hex_string or binary_string which did not match the required syntax. The number is a count of the characters in the string which preceded the detection character, including the initial quote or apostrophe.
6.4.6.2.4 – If the word is 'char' then the replacement text is the detection character.
6.4.6.2.5 – If the word is 'linenumber' then the replacement text is the line number of a clause associated with the error. The wording of the message text specifies which clause that is.
6.4.6.2.6 – If the words is 'keywords' then the replacement text is a list of the keywords that the syntax would allow at the context where the error occurred. If there are two keywords they shall be separated by the four characters ' or '. If more, the last shall be preceded by the three characters 'or ' and the others shall be followed by the two characters ', '.
6.4.6.2.7 Replacement text is truncated to #Limit_MessageInsert characters if it would otherwise be longer than that, except for a keywords replacement.
6.4.6.2.8 When an insert is both truncated and appears within quotes in the message, the three characters '...' are inserted in the message after the trailing quote.
⚠️ **GitHub.com Fallback** ⚠️