Skip to content

Commit

Permalink
Make parseMExprString total
Browse files Browse the repository at this point in the history
  • Loading branch information
br4sco committed Feb 5, 2024
1 parent 3ed149c commit 5165995
Show file tree
Hide file tree
Showing 24 changed files with 119 additions and 84 deletions.
2 changes: 1 addition & 1 deletion stdlib/mexpr/anf.mc
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ in
use TestANF in

let _test = _testConstr normalizeTerm in
let _parse = parseMExprStringKeywords [] in
let _parse = parseMExprStringKeywordsExn [] in

let basic = _parse "
let f = (lam x. x) in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/ast-result.mc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mexpr
use TestLang in

let parse =
parseMExprString
parseMExprStringExn
{ _defaultBootParserParseMExprStringArg () with allowFree = true }
in

Expand Down
149 changes: 92 additions & 57 deletions stdlib/mexpr/boot-parser.mc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion stdlib/mexpr/cfa.mc
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,7 @@ mexpr
use Test in

-- Test functions --
let _parse = parseMExprStringKeywords [] in
let _parse = parseMExprStringKeywordsExn [] in
let _testBase: Option PprintEnv -> Expr -> (Option PprintEnv, CFAGraph) =
lam env: Option PprintEnv. lam t: Expr.
match env with Some env then
Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/constant-fold.mc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ use TestLang in
let _parse = lam prog.
typeCheck
(symbolize
(parseMExprString
(parseMExprStringExn
{ _defaultBootParserParseMExprStringArg () with allowFree = false }
prog))
in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/cps.mc
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ mexpr
use Test in

let _parse =
parseMExprString { defaultBootParserParseMExprStringArg with allowFree = true }
parseMExprStringExn { defaultBootParserParseMExprStringArg with allowFree = true }
in

-------------------------
Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/externals.mc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end
mexpr
use Test in

let parse = parseMExprString
let parse = parseMExprStringExn
{ defaultBootParserParseMExprStringArg with allowFree = true } in
let ast1 = parse "
external a: Int -> Int in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/free-vars.mc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let parseProgram : String -> Expr =
let parseArgs =
{defaultBootParserParseMExprStringArg with allowFree = true}
in
let ast = parseMExprString parseArgs str in
let ast = parseMExprStringExn parseArgs str in
symbolizeExpr {symEnvEmpty with allowFree = true} ast
in

Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/generate-json-serializers.mc
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ end
mexpr
use Test in

let parseTest = parseMExprString {
let parseTest = parseMExprStringExn {
defaultBootParserParseMExprStringArg with
allowFree = true
} in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/index.mc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mexpr
use Test in

let test: String -> IndexMap = lam s.
let t = parseMExprStringKeywords [] s in
let t = parseMExprStringKeywordsExn [] s in
indexGen t
in

Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/kcfa.mc
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ mexpr
use KTest in

-- Test functions --
let _parse = parseMExprStringKeywords [] in
let _parse = parseMExprStringKeywordsExn [] in
let _testBase: Option PprintEnv -> Int -> Expr -> (Option PprintEnv, CFAGraph) =
lam env: Option PprintEnv. lam k. lam t: Expr.
match env with Some env then
Expand Down
4 changes: 2 additions & 2 deletions stdlib/mexpr/profiling.mc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ let getProfilerReportCode = lam.
match deref _profilerReportCodeRef with Some t then t
else
use BootParser in
let code = parseMExprStringKeywords ["functionProfileData"] _profilerReportStr in
let code = parseMExprStringKeywordsExn ["functionProfileData"] _profilerReportStr in
modref _profilerReportCodeRef (Some code);
code

Expand Down Expand Up @@ -252,7 +252,7 @@ lang MExprProfileInstrument = MExprAst + BootParser
let emptyEnv = mapEmpty nameCmp in
let env = collectToplevelFunctions emptyEnv t in
bindall_ [
parseMExprStringKeywords [] (_profilerInitStr env),
parseMExprStringKeywordsExn [] (_profilerInitStr env),
ulet_ "" (instrumentProfilingH env t),
getProfilerReportCode ()]
end
Expand Down
2 changes: 1 addition & 1 deletion stdlib/mexpr/utils.mc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ utest pp (substituteIdentifiers replace (expr "x")) with pp (expr "y") using eqS
let parseProgram : String -> Expr =
lam str.
let parseArgs = {defaultBootParserParseMExprStringArg with allowFree = true} in
let ast = parseMExprString parseArgs str in
let ast = parseMExprStringExn parseArgs str in
symbolizeAllowFree ast
in

Expand Down
2 changes: 1 addition & 1 deletion stdlib/parser/tool.mc
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ let runParserGenerator : {synFile : String, outFile : String} -> () = lam args.
use LetDeclAst in
use UseAst in
use BootParser in
let parse = parseMExprString {_defaultBootParserParseMExprStringArg () with allowFree = true} in
let parse = parseMExprStringExn {_defaultBootParserParseMExprStringArg () with allowFree = true} in
let body = parse
(strJoin "\n"
[ " let config = {errors = ref [], content = content} in"
Expand Down
2 changes: 1 addition & 1 deletion stdlib/peval/peval.mc
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ in
let _toString = utestDefaultToString expr2str expr2str in

let _parse =
parseMExprString
parseMExprStringExn
{ _defaultBootParserParseMExprStringArg () with allowFree = true }
in

Expand Down
4 changes: 2 additions & 2 deletions stdlib/tuning/context-expansion.mc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ lang ContextExpand = HoleAst
sem _wrapReadFile (env : CallCtxEnv) (tuneFile : String) =
| tm ->
use BootParser in
let impl = parseMExprStringKeywords [] "
let impl = parseMExprStringKeywordsExn [] "
let eqSeq = lam eq. lam s1. lam s2.
recursive let work = lam s1. lam s2.
match (s1, s2) with ([h1] ++ t1, [h2] ++ t2) then
Expand Down Expand Up @@ -277,7 +277,7 @@ let anf = compose normalizeTerm symbolize in

let debug = false in
let parse = lam str.
let ast = parseMExprStringKeywords holeKeywords str in
let ast = parseMExprStringKeywordsExn holeKeywords str in
let ast = makeKeywords ast in
symbolize ast
in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tuning/dependency-analysis.mc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ use TestLang in

let debug = false in
let parse = lam str.
let ast = parseMExprStringKeywords holeKeywords str in
let ast = parseMExprStringKeywordsExn holeKeywords str in
let ast = makeKeywords ast in
symbolize ast
in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tuning/hole-cfa.mc
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ use Test in

let debug = false in
let parse = lam str.
let ast = parseMExprStringKeywords holeKeywords str in
let ast = parseMExprStringKeywordsExn holeKeywords str in
let ast = makeKeywords ast in
symbolize ast
in
Expand Down
6 changes: 3 additions & 3 deletions stdlib/tuning/instrumentation.mc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ lang Instrumentation = MExprAst + HoleAst + TailPositions
in\n"
, "()\n"
] in
let ex = use BootParser in parseMExprStringKeywords [] str in
let ex = use BootParser in parseMExprStringKeywordsExn [] str in
let str2name = lam str.
use MExprFindSym in
match findName str ex with Some n then n
Expand Down Expand Up @@ -325,7 +325,7 @@ lang Instrumentation = MExprAst + HoleAst + TailPositions
in"
, "()\n"
] in
let ex = use BootParser in parseMExprStringKeywords [] str in
let ex = use BootParser in parseMExprStringKeywordsExn [] str in
let fun = use MExprFindSym in
match findName "dumpLog" ex with Some n then n else error "impossible" in
(ex, fun)
Expand Down Expand Up @@ -372,7 +372,7 @@ let debugPrintLn = lam debug.
in

let parse = lam str.
let ast = parseMExprStringKeywords holeKeywords str in
let ast = parseMExprStringKeywordsExn holeKeywords str in
let ast = makeKeywords ast in
symbolize ast
in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tuning/nested.mc
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ use TestLang in

let debug = false in
let parse = lam str.
let ast = parseMExprStringKeywords holeKeywords str in
let ast = parseMExprStringKeywordsExn holeKeywords str in
let ast = makeKeywords ast in
symbolize ast
in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tuning/tail-positions.mc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ use TestLang in
let debug = false in

let parse = lam str.
let ast = parseMExprStringKeywords [] str in
let ast = parseMExprStringKeywordsExn [] str in
symbolize ast
in

Expand Down
2 changes: 1 addition & 1 deletion stdlib/tuning/tune-file.mc
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ let tuneFileReadTable : String -> LookupTable = lam file.
let n = string2int (head rows) in
let strVals = subsequence rows 1 n in
let strVals = map (lam x. get (strSplit ": " x) 1) strVals in
map (parseMExprStringKeywords []) strVals
map (parseMExprStringKeywordsExn []) strVals
2 changes: 1 addition & 1 deletion stdlib/tuning/tune-stats.mc
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ use TestLang in
let debug = true in

let parse = lam str.
let ast = parseMExprStringKeywords holeKeywords str in
let ast = parseMExprStringKeywordsExn holeKeywords str in
let ast = makeKeywords ast in
symbolize ast
in
Expand Down
2 changes: 1 addition & 1 deletion stdlib/tuning/tune.mc
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ let debug = false in
let timeSensitive = false in

let parse = lam str.
let ast = parseMExprStringKeywords holeKeywords str in
let ast = parseMExprStringKeywordsExn holeKeywords str in
let ast = makeKeywords ast in
symbolize ast
in
Expand Down

0 comments on commit 5165995

Please sign in to comment.