Shells in OCaml
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Simplify redirection AST

Substitute the default FDs into the various redirection operators.

+30 -25
+17 -12
src/lib/ast.ml
··· 435 435 let b = io_redirect b.value in 436 436 a @ [ b ] 437 437 438 + and io_op_default_fd : io_op -> io_number = function 439 + | Io_op_less -> 0 440 + | Io_op_lessand -> 0 441 + | _ -> 1 442 + 438 443 and io_redirect : CST.io_redirect -> io_redirect = 439 444 fun x -> 440 445 match x with 441 446 | IoRedirect_IoFile a -> 442 447 let a = io_file a.value in 443 - IoRedirect_IoFile a 448 + IoRedirect_IoFile (io_op_default_fd (fst a), a) 444 449 | IoRedirect_IoNumber_IoFile (a, b) -> 445 450 let a = io_number a in 446 451 let b = io_file b.value in 447 - IoRedirect_IoNumber_IoFile (a, b) 452 + IoRedirect_IoFile (a, b) 448 453 | IoRedirect_IoHere a -> 449 454 let a = io_here a.value in 450 - IoRedirect_IoHere a 455 + IoRedirect_IoHere (0, a) 451 456 | IoRedirect_IoNumber_IoHere (a, b) -> 452 457 let a = io_number a in 453 458 let b = io_here b.value in 454 - IoRedirect_IoNumber_IoHere (a, b) 459 + IoRedirect_IoHere (a, b) 455 460 456 461 and io_file : CST.io_file -> io_file = 457 462 fun x -> 458 463 match x with 459 464 | IoFile_Less_FileName a -> 460 465 let a = filename a.value in 461 - IoFile_Less_FileName a 466 + (Io_op_less, a) 462 467 | IoFile_LessAnd_FileName a -> 463 468 let a = filename a.value in 464 - IoFile_LessAnd_FileName a 469 + (Io_op_lessand, a) 465 470 | IoFile_Great_FileName a -> 466 471 let a = filename a.value in 467 - IoFile_Great_FileName a 472 + (Io_op_great, a) 468 473 | IoFile_GreatAnd_FileName a -> 469 474 let a = filename a.value in 470 - IoFile_GreatAnd_FileName a 475 + (Io_op_greatand, a) 471 476 | IoFile_DGreat_FileName a -> 472 477 let a = filename a.value in 473 - IoFile_DGreat_FileName a 478 + (Io_op_dgreat, a) 474 479 | IoFile_LessGreat_FileName a -> 475 480 let a = filename a.value in 476 - IoFile_LessGreat_FileName a 481 + (Io_op_lessgreat, a) 477 482 | IoFile_Clobber_FileName a -> 478 483 let a = filename a.value in 479 - IoFile_Clobber_FileName a 484 + (Io_op_clobber, a) 480 485 481 486 and filename : CST.filename -> filename = 482 487 fun x -> ··· 718 723 (a, b) 719 724 720 725 and io_number : CST.io_number -> io_number = 721 - fun x -> match x with IONumber a -> IONumber a 726 + fun x -> match x with IONumber a -> int_of_string a 722 727 723 728 let of_program = program 724 729
+1
src/lib/eval.ml
··· 38 38 class default_ctx_fold = 39 39 object (_) 40 40 inherit [ctx] Ast.fold 41 + method int _ ctx = ctx 41 42 method string _ ctx = ctx 42 43 method char _ ctx = ctx 43 44 method option f v ctx = Option.fold ~none:ctx ~some:(fun i -> f i ctx) v
+12 -13
src/lib/sast.ml
··· 91 91 and redirects = io_redirect list 92 92 93 93 and io_redirect = 94 - | IoRedirect_IoFile of io_file 95 - | IoRedirect_IoNumber_IoFile of io_number * io_file 96 - | IoRedirect_IoHere of io_here 97 - | IoRedirect_IoNumber_IoHere of io_number * io_here 94 + | IoRedirect_IoFile of io_number * io_file 95 + | IoRedirect_IoHere of io_number * io_here 98 96 99 - and io_file = 100 - | IoFile_Less_FileName of filename 101 - | IoFile_LessAnd_FileName of filename 102 - | IoFile_Great_FileName of filename 103 - | IoFile_GreatAnd_FileName of filename 104 - | IoFile_DGreat_FileName of filename 105 - | IoFile_LessGreat_FileName of filename 106 - | IoFile_Clobber_FileName of filename 97 + and io_op = 98 + | Io_op_less 99 + | Io_op_lessand 100 + | Io_op_great 101 + | Io_op_greatand 102 + | Io_op_dgreat 103 + | Io_op_lessgreat 104 + | Io_op_clobber 107 105 106 + and io_file = io_op * filename 108 107 and filename = word 109 108 110 109 and io_here = ··· 199 198 and subshell_kind = SubShellKindBackQuote | SubShellKindParentheses 200 199 and name = Name of string 201 200 and assignment_word = name * word 202 - and io_number = IONumber of string 201 + and io_number = int