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
|
include<"core/stringeater.stanza">
include<"compiler/lexer.stanza">
include<"compiler/parser.stanza">
include<"compiler/rdparser2.stanza">
include<"compiler/macro-utils.stanza">
include("firrtl-ir.stanza")
include("ir-utils.stanza")
include("ir-parser.stanza")
include("passes.stanza")
include("widthsolver.stanza")
defpackage chmain :
import core
import verse
import chipper.parser
import chipper.passes
import stanza.lexer
import stanza.parser
defn split (s:String,c:Char) -> List<String> :
val empty = ""
defn next-word (s:String,i:Int) -> String|False :
if i == length(s) : false
else:
if (s[i] == c): substring(s,0,i)
else: next-word(s,i + 1)
val next-str = next-word(s,0)
if next-str == false : list()
else if next-str == empty : split(substring(s,1,length(s)),c)
else :
val str = next-str as String
List(str,split(substring(s,length(str)+1,length(s)),c))
defn main () :
val arg = commandline-arguments()
println(arg)
val args = split(arg,' ')
println(args)
println(length(args))
val lexed = lex-file(args[1])
val c = parse-firrtl(lexed)
println(c)
run-passes(c)
main()
; [a b c] <- a tuple
;
; val rest = List(1,2,3)
; val b = List(0,rest) --> (0,1,2,3)
; val c = list(0,rest) --> (0,(1,2,3))
; label<Int> myret :
; for i in 0 to 10 do :
; if i == 5:
; myret(i)
; 0
; val v = Vector<Int>()
; add(v,10)
; add(v,20)
; add(v,32)
; for x in v do :
; println(x)
|