File: DESIREDRDR.c

package info (click to toggle)
qepcad 1.74%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,848 kB
  • sloc: ansic: 27,242; cpp: 2,995; makefile: 1,287; perl: 91
file content (118 lines) | stat: -rw-r--r-- 3,652 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*======================================================================
                      DESIREDRDR(; F,t)

Desired cell condition read, robust.
  
\Output  
  \parm{F} is a condition for desired cells.
  \parm{t} is 1 if successful, 0 otherwise.
======================================================================*/
#include "qepcad.h"

void DESIREDRDR(Word *F_, Word *t_)
{
       Word C,C1,F,F1,F2,R,V1,V2,p,t;
       /* hide C,C1,R,V1,V2,t; */

Step1: /* Atomic condition. */
       F = NIL;
       t = 1;
       C = CREADB(); if (C == '[') goto Step2;
       BKSP(); 
       if (DIGIT(C)) 
         V1 = AREAD();
       else
         {CATTRNRDR(&V1,&t);  if (t == 0) goto Return;}
       RLOPRDR(&R,&t); if (t == 0) goto Return;
       C = CREADB(); BKSP();
       if (DIGIT(C))
         V2 = AREAD();
       else
	 {CATTRNRDR(&V2,&t); if (t == 0) goto Return;}
       F = LIST3(R,V1,V2);
       goto Return;

Step2: /* Negation. */
       C = CREADB(); if (C != '~') { BKSP(); goto Step3; }
       DESIREDRDR(&F1,&t); if (t == 0) goto Return;
       C = CREADB();
       if (C != ']')
         { SWRITE("Error DESIREDRDR: ']' was expected.\n"); goto Step11; }
       F = LIST2(NOTOP,F1); goto Return;

Step3: /* Read in the first formula. */
       DESIREDRDR(&F1,&t); if (t == 0) goto Return;

Step4: /* Redundant square brakets. */
       C = CREADB(); if (C == ']') { F = F1; goto Return; }
       BKSP();

Step5: /* Indentify the logical operator. */
       LGOPRDR(&p,&t); if (t == 0) goto Return;
       switch (p)
         {
         case ANDOP:     goto Step6; break;
         case OROP:      goto Step7; break;
         case RIGHTOP:   goto Step8; break;
         case LEFTOP:    goto Step9; break;
         case EQUIOP:    goto Step10; break;
         case NOTOP:     {
                         SWRITE("Error DESIREDRDR: '~' must not be here.\n"); 
                         goto Step11; 
                         }
         }

Step6: /* Conjunction. */
       F = LIST2(F1,ANDOP);
       do
         {
         DESIREDRDR(&F2,&t); if (t == 0) goto Return;
         F = COMP(F2,F);
         C1 = CREADB();
         if (C1 == ']') { F = INV(F); goto Return; }
         BKSP(); LGOPRDR(&p,&t); if (t == 0) goto Return;
         if (p != ANDOP)
           { SWRITE("Error DESIREDRDR: '/\\' was expected.\n"); goto Step11; }
         } 
       while (1);

Step7: /* Disjunction. */
       F = LIST2(F1,OROP);
       do
         {
         DESIREDRDR(&F2,&t); if (t == 0) goto Return;
         F = COMP(F2,F);
         C1 = CREADB();
         if (C1 == ']') { F = INV(F); goto Return; }
         BKSP(); LGOPRDR(&p,&t); if (t == 0) goto Return;
         if (p != OROP)
           { SWRITE("Error DESIREDRDR: '\\/' was expected.\n"); goto Step11; }
         } 
       while (1);

Step8: /* $\Rightarrow$. */
       DESIREDRDR(&F2,&t); if (t == 0) goto Return;
       C = CREADB();
       if (C != ']') { SWRITE("Error DESIREDRDR: ']' was expected.\n"); goto Step11; }
       F = LIST3(RIGHTOP,F1,F2); goto Return;

Step9: /* $\Leftarrow$. */
       DESIREDRDR(&F2,&t); if (t == 0) goto Return;
       C = CREADB();
       if (C != ']') { SWRITE("Error DESIREDRDR: ']' was expected.\n"); goto Step11; }
       F = LIST3(LEFTOP,F1,F2); goto Return;

Step10: /* $\LeftRightarrow$. */
       DESIREDRDR(&F2,&t); if (t == 0) goto Return;
       C = CREADB();
       if (C != ']') { SWRITE("Error DESIREDRDR: ']' was expected.\n"); goto Step11; }
       F = LIST3(EQUIOP,F1,F2); goto Return;

Step11: /* Error exit. */
       DIELOC(); t = 0; goto Return;

Return: /* Prepare for return. */
       *F_ = F;
       *t_ = t;
       return;
}