.common "hp_com.r.i"; .scanner getchar; .symbol char; .ext_term NEWLINE EOS ; expression -> { constant | command } ( NEWLINE. | EOS. ? call print (ERROUT, "*c: unrecognized command*n.", ? char) ) ; constant -> ! floating ctod ! while (char == ' 'c) ! call getchar '.' ! call push (ctod (line, scanptr)) ! scanptr -= 1 | '0' : '9' ! call push (ctod (line, scanptr)) ! scanptr -= 1 ; command -> ! integer i ! logical sound ! while (char == ' 'c) ! call getchar 'p' ! if (sound (1)) ! call print (STDOUT, "*d*n.", stack (sp)) | 'P' ! for (i = 1; i <= sp; i += 1) ! call print (STDOUT, "*d*n.", stack (i)) | '+' ! if (sound (2)) { ! stack (sp - 1) += stack (sp) ! sp -= 1 ! } | '-' ! if (sound (2)) { ! stack (sp - 1) -= stack (sp) ! sp -= 1 ! } | '*' ! if (sound (2)) { ! stack (sp - 1) *= stack (sp) ! sp -= 1 ! } | '/' ! if (sound (2)) { ! stack (sp - 1) /= stack (sp) ! sp -= 1 ! } | '^' ! if (sound (2)) { ! stack (sp - 1) = stack (sp - 1) ** stack (sp) ! sp -= 1 ! } | 'd' ! if (sound (1)) ! sp -= 1 | 'D' ! sp = 0 | '<' ! if (sound (2)) { ! if (stack (sp - 1) < stack (sp)) ! stack (sp - 1) = 1.0 ! else ! stack (sp - 1) = 0.0 ! sp -= 1 ! } | '=' ! if (sound (2)) { ! if (stack (sp - 1) == stack (sp)) ! stack (sp - 1) = 1.0 ! else ! stack (sp - 1) = 0 ! sp -= 1 ! } | '>' ! if (sound (2)) { ! if (stack (sp - 1) > stack (sp)) ! stack (sp - 1) = 1.0 ! else ! stack (sp - 1) = 0 ! sp -= 1 ! } | '&' ! if (sound (2)) { ! if (stack (sp - 1) ~= 0 & stack (sp) ~= 0) ! stack (sp - 1) = 1.0 ! else ! stack (sp - 1) = 0.0 ! sp -= 1 ! } | '|' ! if (sound (2)) { ! if (stack (sp - 1) ~= 0 | stack (sp) ~= 0) ! stack (sp - 1) = 1.0 ! else ! stack (sp - 1) = 0.0 ! sp -= 1 ! } | '~' ! if (sound (1)) ! if (stack (sp) ~= 0) ! stack (sp) = 0 ! else ! stack (sp) = 1.0 ;