Skip to content

Commit 70fa011

Browse files
committed
Move ParseTree library and other PEG-specific things to tools/peg
ParseTree is a PEG type, not specific to the compiler. PEG and compiler depend on each other, but moving specific parts to their directories still makes sense.
1 parent 0f488b8 commit 70fa011

19 files changed

+39
-24
lines changed

compiler/DeriveEq.fir

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Grammar
22
import Lexer
3-
import PegTestLib
4-
import Scanner
3+
import Peg.PegTestLib
4+
import Compiler.Scanner
55

66
main(args: Array[Str]):
77
if args.len() < 2:
@@ -216,6 +216,7 @@ type Token:
216216
line: U32
217217
col: U32")
218218

219+
# args: -iPeg=tools/peg -iCompiler=compiler
219220
# args after: -- --test
220221
# expected stdout:
221222
# impl[Eq[t]] Eq[Option[t]]:

compiler/ExprGrammarTest.fir

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Grammar
22
import Lexer
3-
import PegTestLib
3+
import Peg.PegTestLib
44

55

66
main(args: Array[Str]):
@@ -98,6 +98,8 @@ runInlineExprScan(input: Str):
9898
runBlockExprScan(input: Str):
9999
runTestScanner_(input, blockExpr)
100100

101+
# args: -iPeg=tools/peg -iCompiler=compiler
102+
101103
# expected stdout:
102104
# hi
103105
# InlineExpr(PrefixExpr(SimpleExpr(LowerId(1:1:"hi"))))

compiler/Grammar.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is generated file, do not edit.
22

3-
import ParseTree
3+
import Peg.ParseTree
44
import Token
55

66
type NonTerminal:

compiler/Grammar.peg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ParseTree
1+
import Peg.ParseTree
22
import Token
33

44
type Terminal = Token

compiler/ImplGrammarTest.fir

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Grammar
22
import Lexer
3-
import PegTestLib
3+
import Peg.PegTestLib
44

55

66
main(args: Array[Str]):
@@ -20,6 +20,8 @@ impl[ToStr[a]] ToStr[Vec[a]]:
2020
runTopDecl(input: Str):
2121
runTestScanner_(input, topDecl)
2222

23+
# args: -iPeg=tools/peg -iCompiler=compiler
24+
2325
# expected stdout:
2426
# impl Foo[T]
2527
# TopDecl(

compiler/ImportGrammarTest.fir

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Grammar
22
import Lexer
3-
import PegTestLib
3+
import Peg.PegTestLib
44

55

66
main(args: Array[Str]):
@@ -15,6 +15,8 @@ import Foo.Bar.Baz")
1515
runTopDecl(input: Str):
1616
runTestScanner_(input, topDecl)
1717

18+
# args: -iPeg=tools/peg -iCompiler=compiler
19+
1820
# expected stdout:
1921
# import Foo
2022
# TopDecl(ImportDecl(Import(1:1:"import"), UpperId(1:8:"Foo")))

compiler/TopFunDeclGrammarTest.fir

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Grammar
22
import Lexer
3-
import PegTestLib
3+
import Peg.PegTestLib
44

55

66
main(args: Array[Str]):
@@ -18,6 +18,8 @@ f():
1818
runTopDecl(input: Str):
1919
runTestScanner_(input, topDecl)
2020

21+
# args: -iPeg=tools/peg -iCompiler=compiler
22+
2123
# expected stdout:
2224
# f(): 1
2325
# TopDecl(

compiler/TraitGrammarTest.fir

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Grammar
22
import Lexer
3-
import PegTestLib
3+
import Peg.PegTestLib
44

55

66
main(args: Array[Str]):
@@ -26,6 +26,8 @@ trait Blah[t]:
2626
runTopDecl(input: Str):
2727
runTestScanner_(input, topDecl)
2828

29+
# args: -iPeg=tools/peg -iCompiler=compiler
30+
2931
# expected stdout:
3032
# trait RecRow[t]
3133
# TopDecl(

compiler/TypeGrammarTest.fir

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Grammar
22
import Lexer
3-
import PegTestLib
3+
import Peg.PegTestLib
44

55
main(args: Array[Str]):
66
if args.len() > 2:
@@ -80,6 +80,8 @@ type MapResult[iter, item, b, exnOld, exnNew]:
8080

8181
()
8282

83+
# args: -iPeg=tools/peg -iCompiler=compiler
84+
8385
# expected stdout:
8486
# asdf
8587
# Type_(LowerId(1:1:"asdf"))

compiler/tests/parse.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ source "${SCRIPT_DIR}/common.sh"
1212

1313
for f in "${files[@]}"; do
1414
echo $f
15-
./target/release/fir compiler/Parser.fir -- "$f"
15+
./target/release/fir -iCompiler=compiler -iPeg=tools/peg compiler/Parser.fir -- "$f"
1616
if [ $? -ne 0 ]; then
1717
exit_code=1
1818
fi

0 commit comments

Comments
 (0)