Advertisement
Pascon_Matteo

Untitled

Dec 20th, 2017
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 2.75 KB | None | 0 0
  1. let rec finder (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.             |"fun"->
  17.                 match last x with
  18.                 |"->" -> (n_tab, unisci_stringhe x)::finder (xs) (n_tab+1) (0) (in_list) (else_list)
  19.                 |_-> (n_tab, unisci_stringhe x)::finder (xs) (n_tab) (0) (in_list) (else_list)
  20.             |"if"->(n_tab, unisci_stringhe x)::finder (xs) (n_tab+1) (in_after_let) (in_list) (n_tab::else_list)
  21.             |"else"->
  22.                 match last x with
  23.                 |"else"->(first_int else_list, unisci_stringhe x)::finder (xs) (first_int else_list+1) (in_after_let) (in_list) (remove_first else_list)
  24.                 |_-> (first_int else_list, unisci_stringhe x)::finder (xs) (first_int else_list) (in_after_let) (in_list) (remove_first else_list)
  25.             |"elif"->(first_int else_list, unisci_stringhe x)::finder (xs) (first_int else_list+1) (in_after_let) (in_list) (else_list)
  26.             |"match"->(n_tab,unisci_stringhe x)::finder (xs) (n_tab) (in_after_let) (in_list) (else_list)
  27.             |"|"->
  28.                 match last x with
  29.                 |"->" ->(n_tab,unisci_stringhe x)::finder (xs) (n_tab+1) (in_after_let) (in_list) (else_list)
  30.                 |_->
  31.                     match next_line xs with
  32.                     |"|"-> (n_tab,unisci_stringhe x)::finder (xs) (n_tab) (in_after_let) (in_list) (else_list)
  33.                     |_ -> (n_tab,unisci_stringhe x)::finder (xs) (n_tab-1) (in_after_let) (in_list) (else_list)
  34.             |"in"->
  35.                 match first_list xs with
  36.                 |[]->(penultimo in_list, unisci_stringhe x)::finder (xs) (n_tab) (in_after_let) (remove_first in_list) (else_list)
  37.                 |_->
  38.                     match in_after_let with
  39.                     |1->(n_tab,unisci_stringhe x)::finder (xs) (n_tab) (0) (in_list) (else_list)
  40.                     |_->(first_int in_list,unisci_stringhe x)::finder (xs) (first_int in_list) (in_after_let) (remove_first in_list) (else_list)
  41.             |_->(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