Advertisement
Pascon_Matteo

F# autoindenter

Dec 11th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. let rec finder1 (work_list:string list list) (n_tab:int) (in_after_let:int) (in_list :int list) (else_list:int list) :(int*string) list=
  2. match work_list with
  3. |[]-> []
  4. |x::xs ->
  5. match x with
  6. |[] -> (0,"")::finder (xs) (0) (0) ([]) (else_list)
  7. |y::ys ->
  8. match y with
  9. |"let"->
  10. match last x with
  11. |"=" -> (n_tab, unisci_stringhe x)::finder (xs) (n_tab+1) (0) (add_element n_tab in_list) (else_list)
  12. |_ ->
  13. match next_line xs with
  14. |"in"->(n_tab, unisci_stringhe x)::finder (xs) (n_tab) (1) (in_list) (else_list)
  15. |_->(n_tab, unisci_stringhe x)::finder (xs) (n_tab) (0) (in_list) (else_list)
  16. |"if"->(n_tab, unisci_stringhe x)::finder (xs) (n_tab+1) (in_after_let) (in_list) (n_tab::else_list)
  17. |"else"->
  18. match last x with
  19. |"else"->(first_int else_list, unisci_stringhe x)::finder (xs) (first_int else_list+1) (in_after_let) (in_list) (remove_first else_list)
  20. |_-> (first_int else_list, unisci_stringhe x)::finder (xs) (first_int else_list) (in_after_let) (in_list) (remove_first else_list)
  21. |"elif"->(first_int else_list, unisci_stringhe x)::finder (xs) (first_int else_list+1) (in_after_let) (in_list) (else_list)
  22. |"match"->(n_tab,unisci_stringhe x)::finder (xs) (n_tab) (in_after_let) (in_list) (else_list)
  23. |"|"->
  24. match last x with
  25. |"->" ->(n_tab,unisci_stringhe x)::finder (xs) (n_tab+1) (in_after_let) (in_list) (else_list)
  26. |_->
  27. match next_line xs with
  28. |"|"-> (n_tab,unisci_stringhe x)::finder (xs) (n_tab) (in_after_let) (in_list) (else_list)
  29. |_ -> (n_tab,unisci_stringhe x)::finder (xs) (n_tab-1) (in_after_let) (in_list) (else_list)
  30. |"in"->
  31. match first_list xs with
  32. |[]->(penultimo in_list, unisci_stringhe x)::finder (xs) (n_tab) (in_after_let) (remove_first in_list) (else_list)
  33. |_->
  34. match in_after_let with
  35. |1->(n_tab,unisci_stringhe x)::finder (xs) (n_tab) (0) (in_list) (else_list)
  36. |_->(first_int in_list,unisci_stringhe x)::finder (xs) (first_int in_list) (in_after_let) (remove_first in_list) (else_list)
  37. |_->(n_tab,unisci_stringhe x)::finder (xs) (n_tab-1) (in_after_let) (in_list) (else_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement