@@ -12,68 +12,73 @@ logger = Logging.ConsoleLogger(logio)
1212
1313pkgspath = joinpath (@__DIR__ , " pkgs" )
1414
15+ exception_count = 0
16+ mismatch_count = 0
17+ file_count = 0
18+ t0 = time ()
1519exceptions = []
20+
1621Logging. with_logger (logger) do
17- t = time ()
18- i = 0
19- iob = IOBuffer ()
20- exception_count = 0
21- mismatch_count = 0
22+ global exception_count, mismatch_count, file_count, t0
2223 for (r, _, files) in walkdir (pkgspath)
2324 for f in files
2425 endswith (f, " .jl" ) || continue
2526 fpath = joinpath (r, f)
26- if isfile (fpath)
27- code = read (fpath, String)
28- expr_cache = fpath* " .Expr"
29- # e2 = JuliaSyntax.fl_parseall(code)
30- e2 = open (deserialize, fpath* " .Expr" )
31- @assert Meta. isexpr (e2, :toplevel )
32- try
33- e1 = JuliaSyntax. parseall (Expr, code, filename= fpath)
34- if ! exprs_roughly_equal (e2, e1)
35- mismatch_count += 1
36- @error (" Parsers succeed but disagree" ,
37- fpath,
38- diff= Text (sprint (show_expr_text_diff, show, e1, e2)),
39- )
40- end
41- catch err
42- err isa InterruptException && rethrow ()
43- ex = (err, catch_backtrace ())
44- push! (exceptions, ex)
45- ref_parse = " success"
46- if length (e2. args) >= 1 && Meta. isexpr (last (e2. args), (:error , :incomplete ))
47- ref_parse = " fail"
48- if err isa JuliaSyntax. ParseError
49- # Both parsers agree that there's an error, and
50- # JuliaSyntax didn't have an internal error.
51- continue
52- end
53- end
27+ isfile (fpath) || continue
5428
55- exception_count += 1
56- parse_to_syntax = " success"
57- try
58- JuliaSyntax. parseall (JuliaSyntax. SyntaxNode, code)
59- catch err2
60- parse_to_syntax = " fail"
29+ code = read (fpath, String)
30+ expr_cache = fpath* " .Expr"
31+ # e2 = JuliaSyntax.fl_parseall(code)
32+ e2 = open (deserialize, fpath* " .Expr" )
33+ @assert Meta. isexpr (e2, :toplevel )
34+ try
35+ e1 = JuliaSyntax. parseall (Expr, code, filename= fpath, ignore_warnings= true )
36+ if ! exprs_roughly_equal (e2, e1)
37+ mismatch_count += 1
38+ @error (" Parsers succeed but disagree" ,
39+ fpath,
40+ diff= Text (sprint (show_expr_text_diff, show, e1, e2)),
41+ )
42+ end
43+ catch err
44+ err isa InterruptException && rethrow ()
45+ ex = (err, catch_backtrace ())
46+ push! (exceptions, ex)
47+ ref_parse = " success"
48+ if length (e2. args) >= 1 && Meta. isexpr (last (e2. args), (:error , :incomplete ))
49+ ref_parse = " fail"
50+ if err isa JuliaSyntax. ParseError
51+ # Both parsers agree that there's an error, and
52+ # JuliaSyntax didn't have an internal error.
53+ continue
6154 end
62- @error " Parse failed" fpath exception= ex parse_to_syntax
6355 end
56+
57+ exception_count += 1
58+ parse_to_syntax = " success"
59+ try
60+ JuliaSyntax. parseall (JuliaSyntax. SyntaxNode, code)
61+ catch err2
62+ parse_to_syntax = " fail"
63+ end
64+ @error " Parse failed" fpath exception= ex parse_to_syntax
6465 end
65- i += 1
66- if i % 100 == 0
67- runtime = time () - t
68- avg = round (runtime/ i* 1000 , digits = 2 )
69- print (iob, " \e [2J\e [0;0H" )
70- println (iob, " $i files parsed" )
71- println (iob, " > $(exception_count) failures compared to reference parser" )
72- println (iob, " > $(mismatch_count) Expr mismatches" )
73- println (iob, " > $(avg) ms per file, $(round (Int, runtime)) s in total" )
74- println (stderr , String (take! (iob)))
66+
67+ file_count += 1
68+ if file_count % 100 == 0
69+ t_avg = round ((time () - t0)/ file_count* 1000 , digits = 2 )
70+ print (stderr , " \r $file_count files parsed, $t_avg ms per file" )
7571 end
7672 end
7773 end
7874end
7975close (logio)
76+
77+ t_avg = round ((time () - t0)/ file_count* 1000 , digits = 2 )
78+
79+ println ()
80+ @info """
81+ Finished parsing $file_count files.
82+ $(exception_count) failures compared to reference parser
83+ $(mismatch_count) Expr mismatches
84+ $(t_avg) ms per file"""
0 commit comments