--- branches/mmeineke/OOPSE/libBASS/BASSyacc.y 2003/03/21 17:42:12 377 +++ trunk/OOPSE/libBASS/BASSyacc.y 2004/01/29 23:01:17 998 @@ -2,7 +2,7 @@ /* define some general tokens */ %token MOLECULE ATOM BOND BEND TORSION POSITION MEMBERS CONSTRAINT -%token COMPONENT START_INDEX DEFINED ORIENTATION +%token COMPONENT START_INDEX DEFINED ORIENTATION ZCONSTRAINT RIGIDBODY /* more advanced tokens */ @@ -11,7 +11,6 @@ double d_val; /* double value */ char * s_ptr; /* string pointer */ struct node_tag* node_ptr; /* pointer to the statement node tree */ - struct integer_list_tag* il_ptr; /*pointer to a int_list item */ } %token INTEGER @@ -21,11 +20,12 @@ %token IDENTIFIER %token QUOTED_STRING +%token LIST_STRING %type stmt %type stmt_list %type assignment -%type member +%type members %type constraint %type orientation %type position @@ -36,9 +36,8 @@ %type bend_block %type torsion_block %type component_block -%type start_index - -%type int_list +%type zconstraint_block +%type rigidbody_block %{ @@ -46,13 +45,13 @@ #include #include -#include -#include -#include -#include +#include "node_list.h" +#include "make_nodes.h" +#include "parse_tree.h" +#include "simError.h" #ifdef IS_MPI #define __is_lex__ -#include +#include "mpiBASS.h" #endif extern int yylineno; @@ -90,11 +89,10 @@ stmt: stmt: assignment { $$ = $1; } - | member { $$ = $1; } + | members { $$ = $1; } | constraint { $$ = $1; } | orientation { $$ = $1; } | position { $$ = $1; } - | start_index { $$ = $1; } | block { $$ = $1; } ; @@ -109,71 +107,34 @@ member: { $$ = assign_s( $1, $3 ); } ; -member: - MEMBERS '(' INTEGER ',' INTEGER ')' ';' - { $$ = members_2( $3, $5 ); } - | MEMBERS '(' INTEGER ',' INTEGER ',' INTEGER ')' ';' - { $$ = members_3( $3, $5, $7 ); } - | MEMBERS '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')' ';' - { $$ = members_4( $3, $5, $7, $9 ); } +members: + MEMBERS LIST_STRING ';' + { $$ = members( $2 ); } ; constraint: - CONSTRAINT '(' INTEGER ')' ';' - { $$ = constraint( (double)$3 ); } - | CONSTRAINT '(' DOUBLE ')' ';' - { $$ = constraint( $3 ); } + CONSTRAINT LIST_STRING ';' + { $$ = constraint( $2 ); } ; orientation: - ORIENTATION '(' DOUBLE ',' DOUBLE ',' DOUBLE ')' ';' - { $$ = orientation( $3, $5, $7 ); } - | ORIENTATION '(' INTEGER ',' DOUBLE ',' DOUBLE ')' ';' - { $$ = orientation( (double)$3, $5, $7 ); } - | ORIENTATION '(' DOUBLE ',' INTEGER ',' DOUBLE ')' ';' - { $$ = orientation( $3, (double)$5, $7 ); } - | ORIENTATION '(' DOUBLE ',' DOUBLE ',' INTEGER ')' ';' - { $$ = orientation( $3, $5, (double)$7 ); } - | ORIENTATION '(' INTEGER ',' INTEGER ',' INTEGER ')' ';' - { $$ = orientation( (double)$3, (double)$5, (double)$7 ); } - | ORIENTATION '(' DOUBLE ',' INTEGER ',' INTEGER ')' ';' - { $$ = orientation( $3, (double)$5, (double)$7 ); } - | ORIENTATION '(' INTEGER ',' DOUBLE ',' INTEGER ')' ';' - { $$ = orientation( (double)$3, $5, (double)$7 ); } - | ORIENTATION '(' INTEGER ',' INTEGER ',' DOUBLE ')' ';' - { $$ = orientation( (double)$3, (double)$5, $7 ); } + ORIENTATION LIST_STRING ';' + { $$ = orientation( $2 ); } ; position: - POSITION '(' DOUBLE ',' DOUBLE ',' DOUBLE ')' ';' - { $$ = position( $3, $5, $7 ); } - | POSITION '(' INTEGER ',' DOUBLE ',' DOUBLE ')' ';' - { $$ = position( (double)$3, $5, $7 ); } - | POSITION '(' DOUBLE ',' INTEGER ',' DOUBLE ')' ';' - { $$ = position( $3, (double)$5, $7 ); } - | POSITION '(' DOUBLE ',' DOUBLE ',' INTEGER ')' ';' - { $$ = position( $3, $5, (double)$7 ); } - | POSITION '(' INTEGER ',' INTEGER ',' INTEGER ')' ';' - { $$ = position( (double)$3, (double)$5, (double)$7 ); } - | POSITION '(' DOUBLE ',' INTEGER ',' INTEGER ')' ';' - { $$ = position( $3, (double)$5, (double)$7 ); } - | POSITION '(' INTEGER ',' DOUBLE ',' INTEGER ')' ';' - { $$ = position( (double)$3, $5, (double)$7 ); } - | POSITION '(' INTEGER ',' INTEGER ',' DOUBLE ')' ';' - { $$ = position( (double)$3, (double)$5, $7 ); } + POSITION LIST_STRING ';' + { $$ = position( $2 ); } ; -start_index: - START_INDEX int_list ';' - { $$ = start_index( $2 ); } - ; - block: molecule_block { $$ = $1; } | atom_block { $$ = $1; } | bond_block { $$ = $1; } | bend_block { $$ = $1; } | torsion_block { $$ = $1; } + | zconstraint_block { $$ = $1; } + | rigidbody_block { $$ = $1; } | component_block { $$ = $1; } ; @@ -201,12 +162,22 @@ torsion_block: TORSION ARRAY_INDEX '{' stmt_list '}' { $$ = torsion_blk( $2, $4 ); } ; - + +zconstraint_block: + ZCONSTRAINT ARRAY_INDEX '{' stmt_list '}' + { $$ = zconstraint_blk( $2, $4 ); } + ; + +rigidbody_block: + RIGIDBODY ARRAY_INDEX '{' stmt_list '}' + { $$ = rigidbody_blk( $2, $4 ); } + ; + component_block: COMPONENT '{' stmt_list '}' { $$ = component_blk( $3 ); } ; - + stmt_list: stmt { $$ = $1; } | stmt_list stmt { @@ -216,24 +187,12 @@ int_list: } ; -int_list: - '<' INTEGER { $$ = il_node( $2 ); } - | int_list ',' INTEGER { - struct integer_list_tag* temp; - temp = il_node( $3 ); - $1->next = temp; - temp->prev = $1; - $$ = temp; - } - | int_list '>' { $$ = il_top( $1 ); } - ; - %% int yyerror( char *err_msg ){ - sprintf( painCave.errMsg, "yacc parse error in %s at line %d: %s\n", - yyfile_name->my_name, yylineno, err_msg ); + sprintf( painCave.errMsg, "OOPSE parse error in %s at line %d: %s\n", + yyfile_name->my_name, yylineno + 1, err_msg ); painCave.isFatal = 1; simError(); return 0;