MUMPS Programming/syntax
(Redirected from Programming:MUMPS syntax)
Basic MUMPS Syntax - Lines, Spaces, WhiteSpace, Comments
editMUMPS syntax was designed to be concise in a time of scarce memory. This serves a purpose now in that programs are cognitively concise: a lot more fits in view on a screen or on a page of paper.
- The basic language structure is command command-separator argument.
- The command may be one of the MUMPS commands, like "SET" or "WRITE"
- The command-separator is written as a single space (or blank) between command (SET) and the arguments.
- The argument depends on the command.
- The argument can be a list of single-arguments (separated by commas) or a single-argument.
- Each single-argument usually is in the form of an expression or group of expression, separated by colons.
- separating each command may be multiple spaces for readability.
- Another command may follow a space on the same line.
SET X=1 SET Y=2
- Whitespace - eol is NOT treated as equivalent to space. Each has different role in MUMPS.
- Tabs are also NOT equivalent to a space, but are sometimes treated like space to delineate a label. Traditional MUMPS editors (IDEs) sometimes treat tabs specially, but do not put the tab character into the MUMPS routine.
- Lines are significant to the syntax as each line starts with a tag(line label) and a space or a space when there is no label.
- Comments start with semicolon (;) and go to the end of the line. A line may start with ; and is all comment.
- There is no command termination character (like ; in java or Perl) other than the eol or a space following the argument.
- Assignment requires the explicit command SET or S
SET X=1,Y=2 ; either form full or abbreviated command S S X=1,Y=2 ;
- There is no syntactic role for braces {}
- Expressions are grouped by parenthesis
- Programs ('routines' in traditional MUMPS terminology) have a unique name and consist of a linear sequence of lines.