| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include "acme.h" |
| 8 |
#include "gighyp.h" |
| 9 |
#include "io.h" |
| 10 |
#include "pet2iso.h" |
| 11 |
#include <string.h> |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
void GigaHypra_comment(void) |
| 16 |
{ |
| 17 |
|
| 18 |
if (IO_get_byte()) { |
| 19 |
IO_put_byte(';'); |
| 20 |
do |
| 21 |
IO_put_byte(PET2ISO(GotByte)); |
| 22 |
while (IO_get_byte()); |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
void GigaHypra_operator(void) |
| 29 |
{ |
| 30 |
char middle = PET2ISO(IO_get_byte()); |
| 31 |
|
| 32 |
if ((middle != ';') && (middle != '\0')) { |
| 33 |
if (IO_get_byte() == '!') { |
| 34 |
switch (middle) { |
| 35 |
case 'n': |
| 36 |
IO_put_byte('!'); |
| 37 |
break; |
| 38 |
case 'o': |
| 39 |
IO_put_byte('|'); |
| 40 |
break; |
| 41 |
case 'a': |
| 42 |
IO_put_byte('&'); |
| 43 |
break; |
| 44 |
case '=': |
| 45 |
IO_put_byte('='); |
| 46 |
break; |
| 47 |
case '<': |
| 48 |
IO_put_string(" < "); |
| 49 |
break; |
| 50 |
case '>': |
| 51 |
IO_put_string(" > "); |
| 52 |
break; |
| 53 |
default: |
| 54 |
IO_put_byte('!'); |
| 55 |
IO_put_byte(middle); |
| 56 |
IO_put_byte('!'); |
| 57 |
} |
| 58 |
IO_get_byte(); |
| 59 |
} else { |
| 60 |
IO_put_byte('!'); |
| 61 |
IO_put_byte(middle); |
| 62 |
} |
| 63 |
} else { |
| 64 |
IO_put_byte('!'); |
| 65 |
} |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
void GigaHypra_indent(int indent) |
| 72 |
{ |
| 73 |
if (indent < 8) |
| 74 |
IO_put_byte('\t'); |
| 75 |
IO_put_byte('\t'); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
void GigaHypra_argument_with_instructs(struct Instructs instructs, int indent) |
| 81 |
{ |
| 82 |
int paren = 0; |
| 83 |
int flags = instructs.flags; |
| 84 |
bool ignore_after_comma = FALSE; |
| 85 |
|
| 86 |
|
| 87 |
if ((flags & FLAG_INSERT_SPACE) && (GotByte != SPACE) |
| 88 |
&& (GotByte != ';') && (GotByte != '\0')) |
| 89 |
IO_put_byte(SPACE); |
| 90 |
|
| 91 |
while ((GotByte != ';') && (GotByte != '\0')) { |
| 92 |
if ((GotByte == ',') && (flags & FLAG_TASK_WITH_COMMA)) { |
| 93 |
if (strcmp(instructs.txtOpcode, ACME_po_pet) == 0) { |
| 94 |
|
| 95 |
IO_put_byte('\n'); |
| 96 |
GigaHypra_indent(indent); |
| 97 |
IO_put_string(ACME_po_pet); |
| 98 |
IO_put_byte(' '); |
| 99 |
IO_get_byte(); |
| 100 |
} else { |
| 101 |
ignore_after_comma = TRUE; |
| 102 |
} |
| 103 |
} |
| 104 |
if (ignore_after_comma == TRUE) { |
| 105 |
|
| 106 |
IO_get_byte(); |
| 107 |
continue; |
| 108 |
} |
| 109 |
|
| 110 |
if (GotByte == '!') |
| 111 |
GigaHypra_operator(); |
| 112 |
if (GotByte == '"') { |
| 113 |
|
| 114 |
IO_put_byte(GotByte); |
| 115 |
IO_get_byte(); |
| 116 |
while ((GotByte != '\0') && (GotByte != '"')) { |
| 117 |
if ((GotByte == 0x5f) |
| 118 |
&& (flags & FLAG_CHANGE_LEFTARROW)) |
| 119 |
IO_put_string("\", 13,\""); |
| 120 |
else |
| 121 |
IO_put_byte(PET2ISO(GotByte)); |
| 122 |
IO_get_byte(); |
| 123 |
} |
| 124 |
IO_put_byte('"'); |
| 125 |
if (GotByte == '"') { |
| 126 |
IO_get_byte(); |
| 127 |
if ((GotByte == '\0') |
| 128 |
&& (flags & FLAG_ADD_ZERO)) |
| 129 |
IO_put_string(", 0"); |
| 130 |
} |
| 131 |
} else { |
| 132 |
|
| 133 |
switch (GotByte) { |
| 134 |
case '(': |
| 135 |
if (flags & FLAG_SKIP_OPENING) { |
| 136 |
flags &= ~FLAG_SKIP_OPENING; |
| 137 |
flags |= FLAG_SKIP_CLOSING; |
| 138 |
} else { |
| 139 |
paren++; |
| 140 |
IO_put_byte(PET2ISO(GotByte)); |
| 141 |
} |
| 142 |
break; |
| 143 |
case ')': |
| 144 |
if ((flags & FLAG_SKIP_CLOSING) && (paren == 0)) { |
| 145 |
flags &= ~FLAG_SKIP_CLOSING; |
| 146 |
} else { |
| 147 |
paren--; |
| 148 |
IO_put_byte(PET2ISO(GotByte)); |
| 149 |
} |
| 150 |
break; |
| 151 |
case SHIFTSPACE: |
| 152 |
IO_put_byte(SPACE); |
| 153 |
break; |
| 154 |
default: |
| 155 |
IO_put_byte(PET2ISO(GotByte)); |
| 156 |
} |
| 157 |
IO_get_byte(); |
| 158 |
} |
| 159 |
} |
| 160 |
if (flags & FLAG_ADD_CBM) |
| 161 |
IO_put_string(ACME_cbmformat); |
| 162 |
if (flags & FLAG_ADD_LEFT_BRACE) |
| 163 |
IO_put_byte('{'); |
| 164 |
} |
| 165 |
|
| 166 |
void GigaHypra_argument(int flags) |
| 167 |
{ |
| 168 |
struct Instructs instructs; |
| 169 |
|
| 170 |
instructs.flags = flags; |
| 171 |
GigaHypra_argument_with_instructs(instructs, 0); |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
int GigaHypra_label_definition(void) |
| 178 |
{ |
| 179 |
int count = 0; |
| 180 |
|
| 181 |
do { |
| 182 |
IO_put_byte(PET2ISO(GotByte)); |
| 183 |
count++; |
| 184 |
IO_get_byte(); |
| 185 |
} while ((GotByte != SPACE) && (GotByte != ';') && (GotByte != '\0')); |
| 186 |
return count; |
| 187 |
} |