TMCALGO V2R1: Algorithm Compiler

A.0: Syntax

  • A.1: Grammar
  • A.2: Lexical Syntax

Following is a list of rules for interpreting the TMCALGO Input Grammar specification followed by the TMCALGO Input Grammar specification itself. Don't confuse these rules with the rules for interpreting a TMCALGO program, which is what the grammar defines. Since we're using a grammar to define a program which is used to define other grammars, there is a heavy dose of self-referentiation. If you lose your bearings, get outside and walk fast enough to double your heartrate for at least 20 minutes.

A.1: TMCALGO Input Grammar

  program
    : [ prog-item ... ]
  prog-item
    : <QUOTED-C-CODE>
    : untimed-command
    : STATE <NAME> [ file-spec ] [ NoLog ] state-cmds
    : PARTITION
  file-spec
    : <QUOTED-STRING> [ <PARENSTAT> ]
  state-cmds
    : '{' untimed-commands timed-commands '}'
  untimed-commands
    : [ untimed-command ... ]
  timed-commands
    : [ [ [ '+' ] time ] timed-command ... ]
  time
    : <INTEGER> [ ':' <INTEGER> ... ]
  untimed-command
    : <TMC-STATEMENT>
    : DEPENDING ON <PARENSTAT> <TMC-STATEMENT> 
  timed-command
    : <TEXT-COMMAND>
    : <QUOTED-STRING> ';'
    : VALIDATE <NAME> ';'
    : HOLD UNTIL [ VALID ] <PARENSTAT> timeout
    : HOLD [ AND VALIDATE <NAME> ] timeout
    : RESUME <NAME> ';'
    : untimed-command 
  timeout
    : ';'
    : OR time ';'
    : OR time ELSE timed-command

A.2: TMCALGO Lexical Syntax

<TEXT-COMMAND>
A text command is a written instrument command prefixed by a right angle-bracket (>). The syntax must match that of the command client/server pair. For example:
              > Lamp On
with the exception that the command text can be prefixed with an underscore character to suppress logging:
              > _Lamp On
<TMC-STATEMENT>
As you might guess, a TMC statement bracketed by curly braces ({}). The syntax is not checked until TMC gets it. For example:
              { msg( 0, "Having Fun, wish you were here!"; }

At the top level, the braces are removed before sending the statement on to TMC, making top-level TMC definitions possible.

<INTEGER>
An integer consists of one or more digits.
<NAME>
A name is a unique C-style symbol (begins with a letter and consists of letters, numbers and/or underscore characters) used to identify a state or a TMC variable to be validated.
<QUOTED-C-CODE>
C code may be embedded in a TMCALGO program in the same way as in TMC. A line beginning with '%{' marks the beginning of the C code and a line beginning with '%}' marks the end. This code is passed through to the TMC output file complete with the quotation marks, so a double layer of quoting is not required.
<PARENSTAT>
An expression or list enclosed in parentheses. TMCALGO does not perform additional syntax checking on the expression within parentheses except to ensure that nested parentheses balance properly.
<QUOTED-STRING>
A string enclosed in double quotation marks (""). Used for informational strings and to specify input file names.
Comments
Comments begin with the '#' character and continue to the end of the line. You may not append a comment to the end of an experiment command. Neither can you embed a comment within a TMC statement or <QUOTED-C-CODE>, although you can usually use C-style comments there.

Return to Manuals Guide. Written by Norton T. Allen



last updated: Thu Jan 2 10:51:49 2003 webmaster@huarp.harvard.edu
Copyright 2002 by the President and Fellows of Harvard College