# Example MIN file, for testing the parser. # This program doesn't do anything in particular, but it uses all available grammatical constructions. MIN "A.1.0" FLAGS {} ### Types. ### # The type with only one value (and hence no information except arrival time). # This is used only to test subtype declarations. TYPE unit = Nil # The type that represents a character. TYPE char = {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Space} # The type that represents a string. TYPE string = { # Represents the empty string. Nil # Represents the string formed by prepending a character to a string. Cons(!char, !string) } # An 'output' style subtype declaration. SUBTYPE !unit <: !string # The type of a command for the console. TYPE console = { # The command to read a string. Input(?string) # The command to write a string. Print(!string) } # The type for talking to the console. TYPE consoleList = { # The empty conversation. Nil # The conversation formed from a command followed by a conversation. Cons(!console, !consoleList) } # An 'input' style subtype declaration. SUBTYPE ?consoleList <: ?unit ### Nodes. ### # Appends the reverse of the input string to 'acc' and sends it to 'ans'. NODE revApp(ans: ?string, acc: !string): ?string = { Nil { :ans = :acc } Cons(c:, cs:) { Cons(:c, :acc) = acc: revApp(:ans, :acc) = :cs } } # Sends the reverse of the input string to 'ans'. NODE rev(ans: ?string): ?string = {} ELSE rev(ans, Nil) ### Main graph. ### # Read a string, reverse it, and print it out again. MAIN: !listConsole = { # Construct a list of commands, and call it 'main'. # Call the unfinished tail of the list 'tail' and add commands to it one by one. main: = tail: # First command: read a string and call it 'data'. :tail = Cons(Input(data:), tail:) # Second command: write a string calculated by reversing 'data'. # The call to 'rev' is inlined somewhat illegibly to test the 'pick' notation. :tail = Cons(Print({ rev(ans:) = :data }:ans), tail:) # No more commands. :tail = Nil # This just to test MERGE and HALT. It doesn't do anything. HALT=MERGE(HALT, HALT, HALT) }:main