Command Language Specification

This document contains the specification of the Shape_edit Command Language (SCL). This is the command language interface to the Alpha_1 c_shape_edit modeling program. File names for SCL commands should use the .scl file name extension.

Keywords

The following are the keywords and operators of the language:
Keywords and operators          Token Name
------------------------------------------
and                             T_AND
const                           T_CONST
commentoutcode                  T_COMMENT_OUT_CODE
else                            T_ELSE
quit                            T_QUIT
false                           T_FALSE
for                             T_FOR
forcollect                      T_FOR_COLLECT
if                              T_IF
include                         T_INCLUDE
not                             T_NOT
or                              T_OR
procedure                       T_PROCEDURE
return                          T_RETURN
seq                             T_SEQ
seqcollect                      T_SEQ_COLLECT
set                             T_SET
true                            T_TRUE
unset                           T_UNSET
while                           T_WHILE
!=                              T_NE
!                               T_NOT
&&                              T_AND
**                              T_EXPONENT
++                              T_INCR
--                              T_DECR
<=                              T_LE
==                              T_EQ
>=                              T_GE
||                              T_OR
;                               T_SEMI_COLON
$;                              T_INTERP_LINE_QUIET
:                               T_LABEL
::                              T_UP_LABEL
<<                              T_BLOCK_BEGIN
>>                              T_BLOCK_END
These will subsequently be referred to by their token names.

Built-in Data Types

The data types of the language are specified with the following regular expressions:
Type            Specification           Token Name
--------------------------------------------------
real            ([0-9]*"."[0-9]+)|      T_FLOAT
                ([0-9]+"."[0-9]*)|
                ([0-9]*"."[0-9]+[eE][+-]?[0-9]+)|
                ([0-9]+"."[0-9]*[eE][+-]?[0-9]+)
integer         [0-9]+                  T_INTEGER
identifier      [a-zA-Z_][a-zA-Z_0-9]*  T_IDENTIFIER
string          \"[^"]*\"               T_STRING
These will also be subsequently referred to by their token names.

Grammar

The grammar of the language is specified as a series of language constructs defined recursively in terms of other constructs, token names (as defined above), and literal punctuation. A construct is specified as a series of optional ("or" choices) constructs separated by vertical bars ("|") i.e.:
construct:      construct-option1 | construct-option2 | ...
Literal characters (punctuation) are enclosed in single quotes (e.g.: ',').

Language Constructs

These are the valid constructs of the language: 
form:           statement | EOS

EOS:            T_SEMI_COLON | T_INTERP_LINE_QUIET

statement:      val_stmt
        |       labeled_stmt
        |       define_stmt
        |       scl_sys_stmt EOS
        |       include_stmt EOS
        |       T_BLOCK_BEGIN stmt_list T_BLOCK_END

stmt_list:      statement | stmt_list statement

scl_sys_stmt:   T_SET T_IDENTIFIER expr
        |       T_UNSET T_IDENTIFIER
        |       T_QUIT

val_stmt:       expr EOS    | control_stmt  | comment_out_stmt

labeled_stmt:   T_IDENTIFIER T_LABEL val_stmt

comment_out_stmt:   T_COMMENT_OUT_CODE statement

val_stmt_list:  val_stmt    | labeled_stmt 
        |       val_stmt_list val_stmt
        |       val_stmt_list labeled_stmt


control_stmt:   '{' val_stmt_list '}'
        |       T_SEQ '{' val_stmt_list '}'
        |       T_SEQ_COLLECT '{' val_stmt_list '}'
        |       T_WHILE '(' expr ')' val_stmt
        |       T_IF '(' expr ')' val_stmt T_ELSE val_stmt
        |       T_FOR '(' T_IDENTIFIER EOS expr EOS expr EOS expr ')'
                    val_stmt
        |       T_FOR_COLLECT '(' T_IDENTIFIER EOS expr EOS expr EOS expr ')'
                    val_stmt
        |       T_RETURN expr EOS

define_stmt:    T_PROCEDURE T_IDENTIFIER '(' arg_list ')' val_stmt
        |       T_PROCEDURE T_IDENTIFIER '(' ')' val_stmt

include_stmt:   T_INCLUDE T_STRING

arg_list:       arg | arg_list ',' arg

arg:            T_IDENTIFIER

expr:           object
        |       T_INTEGER | T_FLOAT | T_STRING 
        |       T_TRUE | T_FALSE
        |       T_IDENTIFIER '(' expr_list ')'
        |       T_IDENTIFIER '(' ')'
        |       '+' expr
        |       '-' expr
        |       expr '+' expr
        |       expr '-' expr
        |       expr '*' expr
        |       expr '/' expr
        |       expr '%' expr
        |       expr T_EXPONENT expr
        |       expr T_EQ expr
        |       expr T_NE expr
        |       expr '<' expr
        |       expr '>' expr
        |       expr T_GE expr
        |       expr T_LE expr
        |       expr T_AND expr
        |       expr T_OR expr
        |       '(' expr ')'

expr_list:      expr | expr_list ',' expr

object:         T_IDENTIFIER    | object access_list

access:         '.' T_IDENTIFIER
        |       '[' expr ']'

access_list:    access  | access_list access

Comments in SCL Files

Comments may be included in SCL by using the "#" character. The portion of a line of input after a "#" character is ignored by the parser.
        origin : pt( 0, 0 );    # This is a comment.

Current Implementation Notes

The above specification is implemented with a parser to read the text and determine whether it is syntactically correct, and an interpreter to execute the language. The current implementation of the parser is complete, but the interpreter does not implement some of the "extensibility" features (i.e.: programming) of the language.

 Here is a specific list of language constructs that are not supported in the current interpreter:

not
while
for
return
!
++
--
::

C_Shape_Edit User's Manual Home Page 
Alpha_1 User's Manual.
Copyright © 1998, University of Utah
a1-web@gr.cs.utah.edu