Merge pull request #2318 from jwillemsen/jwi-add_forward_profiles
[ACE_TAO.git] / TAO / orbsvcs / tests / Concurrency / CC_command.y
blob76a92e59b23de777d431fa57742475eae9428add
1 /*
2 * ============================================================================
4 * = LIBRARY
5 * TAO/orbsvcs/tests
7 * = FILENAME
8 * CC_command.y
10 * = DESCRIPTION
11 * This is the yacc file for the concurrency service script language.
13 * = AUTHORS
14 * Torben Worm <tworm@cs.wustl.edu>
16 * ============================================================================
19 #include "CC_command.h"
20 #include "ace/ACE.h"
21 #include "orbsvcs/CosConcurrencyControlC.h"
23 void yyerror (const char* s);
24 int yylex(void);
26 extern int line_no;
27 extern char line_buf[500];
28 extern char *yytext;
29 extern CC_CommandList *cmdlist;
32 %union {
33 CC_Command *command;
34 CosConcurrencyControl::lock_mode lock_mode;
35 char *id;
36 int num;
39 %token T_START_CMD T_CREATE_CMD T_LOCK_CMD T_UNLOCK_CMD T_TRYLOCK_CMD
40 %token T_CHANGEMODE_CMD T_SLEEP_CMD T_WAIT_CMD T_REPEAT_CMD T_EXCEP_CMD
41 %token T_PRINT_CMD T_LOOKUP_CMD T_TERM
42 %token T_READ T_IREAD T_UPGRADE T_WRITE T_IWRITE
43 %token <id> T_IDENT Q_STRING
44 %token <num> T_NUM
46 %type <command> cmd
47 %type <id> config_file_name lock_set_name exception_name
48 %type <lock_mode> lock_mode
51 start: /* empty */
52 | cmd_list { cmdlist->add(new CC_Sleep_Cmd(0));
53 /* dummy to check exeption in the last command */
54 if(cmdlist->execute()!=0) //CC_FAIL
55 { printf(" ** Test succeded!!\n"); }
56 else
57 { printf(" ** Test FAILED!!\n"); } }
60 cmd_list: cmd_list cmd { cmdlist->add($2); }
61 | cmd { cmdlist->add($1); }
64 cmd: T_START_CMD config_file_name T_TERM
65 { $$ = new CC_Start_Cmd($2); }
66 | T_CREATE_CMD lock_set_name T_TERM
67 { $$ = new CC_CreateLockSet_Cmd($2); }
68 | T_CREATE_CMD T_TERM
69 { $$ = new CC_CreateLockSet_Cmd(""); }
70 | T_LOCK_CMD lock_set_name lock_mode T_TERM
71 { $$ = new CC_Lock_Cmd($2, $3); }
72 | T_LOCK_CMD lock_mode T_TERM
73 { $$ = new CC_Lock_Cmd("", $2); }
74 | T_UNLOCK_CMD lock_set_name lock_mode T_TERM
75 { $$ = new CC_UnLock_Cmd($2, $3); }
76 | T_UNLOCK_CMD lock_mode T_TERM
77 { $$ = new CC_UnLock_Cmd("", $2); }
78 | T_TRYLOCK_CMD lock_set_name lock_mode T_TERM
79 { $$ = new CC_TryLock_Cmd($2, $3); }
80 | T_TRYLOCK_CMD lock_mode T_TERM
81 { $$ = new CC_TryLock_Cmd("", $2); }
82 | T_CHANGEMODE_CMD lock_set_name lock_mode lock_mode T_TERM
83 { $$ = new CC_ChangeMode_Cmd($2, $3, $4); }
84 | T_CHANGEMODE_CMD lock_mode lock_mode T_TERM
85 { $$ = new CC_ChangeMode_Cmd("", $2, $3); }
86 | T_SLEEP_CMD T_NUM T_TERM
87 { $$ = new CC_Sleep_Cmd($2); }
88 | T_WAIT_CMD T_TERM
89 { $$ = new CC_Wait_Cmd(""); }
90 | T_WAIT_CMD Q_STRING T_TERM
91 { $$ = new CC_Wait_Cmd($2); }
92 | T_PRINT_CMD Q_STRING T_TERM
93 { $$ = new CC_Print_Cmd($2); }
94 | T_LOOKUP_CMD lock_set_name T_TERM
95 { $$ = new CC_Lookup_Cmd($2); }
96 | T_REPEAT_CMD T_NUM T_TERM
97 { cmdlist->setrepeat($2);
98 $$ = new CC_Dummy_Cmd();}
99 | T_EXCEP_CMD exception_name T_TERM
100 { $$ = new CC_Excep_Cmd($2); }
103 config_file_name: T_IDENT {$$ = $1; }
105 lock_set_name: T_IDENT {$$ = $1; }
107 exception_name: T_IDENT {$$ = $1; }
109 lock_mode: T_READ { $$ = CosConcurrencyControl::read; }
110 | T_IREAD { $$ = CosConcurrencyControl::intention_read; }
111 | T_UPGRADE { $$ = CosConcurrencyControl::upgrade; }
112 | T_WRITE { $$ = CosConcurrencyControl::write; }
113 | T_IWRITE { $$ = CosConcurrencyControl::intention_write; }
117 void
118 yyerror (const char *s)
120 ACE_OS::printf ("%d: %s at %s in:\n%s\n",
121 line_no,
123 yytext,
124 line_buf);
125 ACE_OS::exit (-1);