TOC PREV NEXT INDEX

National Institute of Standards and Technology


Appendix E. Production Rules for theRS274/NGC Language


The following is a production rule definition of what combinations of symbols form a valid line of RS274/NGC code. Developers, researchers, and NC programmers and machine operators with computer science backgrounds may find this section useful. NC programmers and machine operators without computer science backgrounds and SAI installers will probably not find it useful.

The term "line" is at the top of the production hierarchy. The productions are arranged alphabetically to make connections easy to trace.

The productions are intended to be unambiguous. That is, no permissible line of code can be interpreted more than one way. To make the productions below entirely unambiguous, it is implicit that if a string of characters that can meet the requirements of an ordinary comment also can be interpreted as a message, that string is a message and not an ordinary comment.

The term comment_character is used in the productions but not defined there. A comment character is any printable character plus space and tab, except for a left parenthesis or right parenthesis. This implies comments cannot be nested.

It is implicit in the production rules that, except inside parentheses, space and tab characters may be ignored, or have been removed by pre-processing.

These production rules do not include constraints implied by the semantics of the Interpreter. Most of the constraints are in terms of combinations of words (as defined below). Many lines of code that are readable under these production rules will not be executable because they violate constraints. Any constraint violation will be detected by the Interpreter and will result in an error message. The error messages are included in Appendix A.

In the productions, a parameter_index is defined as a synonym for real_value. The constraint on a parameter_index is that it must be an integer between 1 and 5399 (inclusive).

E.1 Production Language

The symbols in the productions are mostly standard syntax notation. Meanings of the symbols follow.

= The symbol on the left of the equal sign is equivalent to the expression on the right

+ followed by

| or

. end of production (a production may have several lines)

[ ] zero or one of the expression inside square brackets may occur

{ } zero to many of the expression inside curly braces may occur

( ) exactly one of the expression inside parentheses must occur

E.2 Productions

Any term in this subsection that is used on the right of an equal sign but is not defined in this subsection (i.e., does not appear on the left in any definition) is defined in the next subsection in terms of characters.

arc_tangent_combo = arc_tangent + expression + divided_by + expression .
binary_operation = binary_operation1 | binary_operation2 | binary_operation3 .
binary_operation1 = power .
binary_operation2 = divided_by | modulo | times .
binary_operation3 = and | exclusive_or | minus | non_exclusive_or | plus .
comment = message | ordinary_comment .
comment_character = see explanation above .
digit = zero | one | two | three | four | five | six | seven | eight | nine .
expression = left_bracket + real_value + { binary_operation + real_value } + right_bracket .
letter_a = big_a | little_a .
letter_b = big_b | little_b .
letter_c = big_c | little_c .
letter_d = big_d | little_d .
letter_f = big_f | little_f .
letter_g = big_g | little_g .
letter_h = big_h | little_h .
letter_i = big_i | little_i .
letter_j = big_j | little_j .
letter_k = big_k | little_k .
letter_l = big_l | little_l .
letter_m = big_m | little_m .
letter_n = big_n | little_n .
letter_p = big_p | little_p .
letter_q = big_q | little_q .
letter_r = big_r | little_r .
letter_s = big_s | little_s .
letter_t = big_t | little_t .
letter_x = big_x | little_x .
letter_y = big_y | little_y .
letter_z = big_z | little_z .
line = [block_delete] + [line_number] + {segment} + end_of_line .
line_number = letter_n + digit + [digit] + [digit] + [digit] + [digit] .
message = left_parenthesis + {white_space} + letter_m + {white_space} + letter_s +
{white_space} + letter_g + {white_space} + comma + {comment_character} +
right_parenthesis .
mid_line_letter = letter_a | letter_b | letter_c| letter_d | letter_f | letter_g | letter_h | letter_i
| letter_j | letter_k | letter_l | letter_m | letter_p | letter_q | letter_r | letter_s | letter_t
| letter_x | letter_y | letter_z .
mid_line_word = mid_line_letter + real_value .
ordinary_comment = left_parenthesis + {comment_character} + right_parenthesis .
ordinary_unary_combo = ordinary_unary_operation + expression .
ordinary_unary_operation =
absolute_value | arc_cosine | arc_sine | cosine | e_raised_to |
fix_down | fix_up | natural_log_of | round | sine | square_root | tangent .
parameter_index = real_value .
parameter_setting = parameter_sign + parameter_index + equal_sign + real_value .
parameter_value = parameter_sign + parameter_index .
real_number =
[ plus | minus ] +
(( digit + { digit } + [decimal_point] + {digit}) | ( decimal_point + digit + {digit})) .
real_value = real_number | expression | parameter_value | unary_combo .
segment = mid_line_word | comment | parameter_setting .
unary_combo = ordinary_unary_combo | arc_tangent_combo .
white_space = space | tab .
E.3 Production Tokens in Terms of Characters

We have omitted the letters and digits in the list below, since they are all the obvious single characters. For example, one is `1', big_a is `A', and little_a is `a'. The list should be used as if these obvious items were included. Note that not every letter of the alphabet is included (E, O, U, V, and W are omitted).

absolute_value = `abs'
and = `and'
arc_cosine = `acos'
arc_sine = `asin'
arc_tangent = `atan'
block_delete = `/'
cosine = `cos'
decimal_point = `.'
divided_by = `/'
equal_sign = `='
exclusive_or = `xor'
e_raised_to = `exp'
end_of_line = ` ` (non-printable newline character)
fix_down = `fix'
fix_up = `fup'
left_bracket = `[`
left_parenthesis = `(`
minus = `-'
modulo = `mod'
natural_log_of = `ln'
non_exclusive_or = `or'
parameter_sign = `#'
plus = `+'
power = `**'
right_bracket = `]'
right_parenthesis = `)'
round = `round'
sine = `sin'
space = ` ` (non-printable space character)
square_root = `sqrt'
tab = ` ` (non-printable tab character)
tangent = `tan'
times = `*'

TOC PREV NEXT INDEX