Skip to content

Commit 8a330f5

Browse files
committed
Only show one group of output
1 parent 2c353c9 commit 8a330f5

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/main/scala/plus/meow/MeowRust/Main.scala

+15-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.codecommit.gll.LineStream
44
import scala.io.Source
55
import plus.meow.MeowRust.parser.Parser
66
import com.codecommit.gll.Success
7+
import com.codecommit.gll.Failure
78

89
/**
910
* MeowRust compiler
@@ -14,8 +15,10 @@ import com.codecommit.gll.Success
1415
* - For example, compare operators requires parentheses to specify associativity
1516
* - Codegen: Derive(...)
1617
* - Register: types, impls...
17-
* - Resolve + Type-check - 1: Generate types for each expression. This also involves picking the most accurate trait impl
18-
* - Disugar: Question marks, etc.
18+
* - Resolve + Type-check - 1: Generate types for each expression.
19+
* This also involves picking the most accurate trait impl,
20+
* and actually instantiate generic functions
21+
* - Disugar: Question marks, etc. Notably, compile matches \w exhaustiveness check
1922
* - Type-check - 2: Checks if subtyping/conversion works. Insert implicit conversions
2023
* - Target generation: Dump LLVM IR
2124
*/
@@ -27,10 +30,16 @@ object Main extends App {
2730
println("Processing file " + file)
2831
val stream = LineStream(Source fromFile file)
2932

30-
val parsed = Parser.parse(stream)
31-
32-
if(parsed exists { _.isInstanceOf[Success[String]] }) {
33-
for(Success(tree, _) <- parsed) { println(tree) }
33+
// First parse-tree / error is with the intended precedence
34+
val parsed = Parser.parse(stream).head
35+
parsed match {
36+
case Failure(data, _) => {
37+
print("Error parsing " + file)
38+
print(data)
39+
}
40+
case Success(tree, _) => {
41+
print("Parser tree:\n" + tree)
42+
}
3443
}
3544
}
3645
}

0 commit comments

Comments
 (0)