Skip to content

Commit 2ce1f1c

Browse files
committed
Update README.md
1 parent 169a635 commit 2ce1f1c

1 file changed

Lines changed: 51 additions & 25 deletions

File tree

README.md

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Scanlib
22

3-
Use Scanspec to validate input files and generate input parsing code in Go, C++14, and Python 3.
3+
Use Scanspec to validate input files and generate input parsing code in C99, C++14, Go, and Python 3.
44

55
## Scanspec
66

@@ -22,37 +22,43 @@ eol
2222
eof
2323
```
2424

25-
``` go
26-
package main
27-
28-
import "fmt"
25+
``` c
26+
#include <stdio.h>
2927

30-
func main() {
31-
var A, B int
32-
fmt.Scan(&A, &B)
28+
int main() {
29+
int A, B;
30+
scanf("%d %d", &A, &B);
3331

32+
return 0;
3433
}
3534
```
3635

3736
``` cpp
38-
// Generated using Scanlib
39-
4037
#include <iostream>
4138

4239
using namespace std;
4340

4441
int main() {
4542
int A, B;
46-
cin >> A;
47-
cin >> B;
43+
cin >> A >> B;
4844

4945
return 0;
5046
}
5147
```
5248

53-
``` py
54-
# Generated using Scanlib
49+
``` go
50+
package main
51+
52+
import "fmt"
53+
54+
func main() {
55+
var A, B int
56+
fmt.Scan(&A, &B)
57+
58+
}
59+
```
5560

61+
``` py
5662
A, B = map(int, input().split())
5763
```
5864

@@ -81,29 +87,24 @@ eof
8187
```
8288

8389
``` cpp
84-
// Generated using Scanlib
85-
8690
#include <iostream>
8791
#include <string>
8892

8993
using namespace std;
9094

9195
int main() {
9296
int R, C;
93-
cin >> R;
94-
cin >> C;
97+
cin >> R >> C;
9598
string G[R];
9699
for (int i = 0; i < R; ++i) {
97100
cin >> G[i];
98101
}
99-
102+
100103
return 0;
101104
}
102105
```
103106

104107
``` py
105-
# Generated using Scanlib
106-
107108
R, C = map(int, input().split())
108109
G = [""] * R
109110
for i in range(0, R):
@@ -138,11 +139,22 @@ string
138139
[]T
139140
```
140141

142+
#### Operators
143+
144+
```
145+
+ - * / **
146+
== != < > <= >=
147+
&& ||
148+
```
149+
150+
The `**` operator performs exponentiation.
151+
141152
#### Check Statements
142153

143154
```
144155
check n > 0, n < 1000
145156
check e > 0, f < 5.0
157+
check n ** 2 < 1000000
146158
```
147159

148160
#### Variable Declarations
@@ -241,10 +253,24 @@ sum(a...): Returns the sum of the arguments. Accepts int, int64, and []int value
241253
toInt64(s, b=10): Parses string s in base b and returns in int64.
242254
```
243255

256+
## CLI
257+
258+
```
259+
go install git.furqansoftware.net/toph/scanlib/cmd/scanlib@latest
260+
```
261+
262+
Evaluate a Scanspec file against an input file:
263+
264+
```
265+
scanlib scanspec input.txt
266+
```
267+
268+
Or read input from stdin:
269+
270+
```
271+
echo "3 2" | scanlib scanspec
272+
```
273+
244274
## TODO
245275

246-
- [x] If Statements
247-
- [x] C Generator
248-
- [x] Go Generator
249276
- [ ] Graph Checks
250-
- [x] CLI Tool

0 commit comments

Comments
 (0)