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
119
120
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
pub const LBCELL: i32 = -5;
//$Procedure M2INTS (Meta 2 --- initialize syntax table)
pub fn M2INTS(
NSYN: i32,
SYNKEY: CharArrayMut,
SYNPTR: &mut [i32],
SYNVAL: CharArrayMut,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut SYNKEY = DummyCharArrayMut::new(SYNKEY, None, LBCELL..);
let mut SYNPTR = DummyArrayMut::new(SYNPTR, LBCELL..);
let mut SYNVAL = DummyCharArrayMut::new(SYNVAL, None, LBCELL..);
let mut KEYWRD = [b' '; 32 as usize];
let mut LSTKEY = [b' '; 32 as usize];
let mut B: i32 = 0;
let mut E: i32 = 0;
let mut PUT: i32 = 0;
//
// Spicelib functions.
//
//
// Local variables.
//
//
// Initialize the symbol table size attributes.
//
spicelib::SSIZEC(NSYN, SYNKEY.as_arg_mut(), ctx)?;
spicelib::SSIZEI(NSYN, SYNPTR.as_slice_mut(), ctx)?;
spicelib::SSIZEC(NSYN, SYNVAL.as_arg_mut(), ctx)?;
//
// Just in case, left justify everything in the values cell
// and set all of the pointer values to 0.
//
for I in 1..=NSYN {
spicelib::LJUST(&SYNVAL[I].to_vec(), &mut SYNVAL[I]);
SYNPTR[I] = 0;
}
//
// Turn the collection of syntax definitions into an array ordered
// by initial keyword (minus any labels).
//
M2SHLL(NSYN, SYNVAL.subarray_mut(1));
//
// Remove any duplicates including a blank at the beginning if
// there is one.
//
PUT = 0;
fstr::assign(SYNVAL.get_mut(0), b" ");
for I in 1..=NSYN {
if fstr::ne(SYNVAL.get(I), SYNVAL.get((I - 1))) {
PUT = (PUT + 1);
let val = SYNVAL.get(I).to_vec();
fstr::assign(SYNVAL.get_mut(PUT), &val);
}
}
spicelib::SSIZEC(NSYN, SYNVAL.as_arg_mut(), ctx)?;
spicelib::SCARDC(PUT, SYNVAL.as_arg_mut(), ctx)?;
//
// Now we will construct the symbol table to go with this collection
// of syntax definitions.
//
fstr::assign(&mut LSTKEY, b" ");
PUT = 0;
for I in 1..=spicelib::CARDC(SYNVAL.as_arg(), ctx)? {
//
// Get the first word, and trim off any attached label. Note that
// since this is supposed to be a keyword, there are no range
// templates or qualifiers attached.
//
spicelib::FNDNWD(&SYNVAL[I], 1, &mut B, &mut E);
M2TRIM(fstr::substr(&SYNVAL[I], B..=E), &mut KEYWRD, ctx);
spicelib::UCASE(&KEYWRD.clone(), &mut KEYWRD, ctx);
//
// If this is a new keyword, put it into the list of keywords and
// change the last keyword.
//
if fstr::ne(&KEYWRD, &LSTKEY) {
PUT = (PUT + 1);
fstr::assign(SYNKEY.get_mut(PUT), &KEYWRD);
fstr::assign(&mut LSTKEY, &KEYWRD);
}
//
// Increment the value in the pointer array.
//
SYNPTR[PUT] = (SYNPTR[PUT] + 1);
}
//
// Set the cardinality of the name and pointer cells.
//
spicelib::SCARDC(PUT, SYNKEY.as_arg_mut(), ctx)?;
spicelib::SCARDI(PUT, SYNPTR.as_slice_mut(), ctx)?;
//
// Finally, blank out all of the non-used parts of the values cell.
//
for I in -5..=-2 {
fstr::assign(SYNVAL.get_mut(I), b" ");
}
Ok(())
}