Navigation
Synopsis The classical toy language, including a specialized IDE.
Description Pico is a toy language that has been used as example over the years in many projects and disguishes, Pico has a single purpose in life: being so simple that specifications of every possible language aspect are so simple that they fit on a few pages. It can be summarized as follows:
  • There are two types: natural numbers and strings.
  • Variables have to be declared.
  • Statements are assignment, if-then-else and while-do.
  • Expressions may contain naturals, strings, variables, addition (+), subtraction (-) and concatenation (||).
  • The operators + and - have operands of type natural and their result is natural.
  • The operator || has operands of type string and its results is also of type string.
  • Tests in if-then-else statement and while-statement should be of type natural.
The following aspects of the Pico language will be discussed:

  • Syntax: Concrete syntax for Pico.
    • Abstract: Abstract syntax for Pico.
      • Load: Convert a Pico parse tree into a Pico abstract syntax tree.
        • Typecheck: Typechecker a Pico program.
          • Evaluate: Evaluate a Pico program.
            • Assembly: Assembly language for Pico.
              • Compile: Compile a Pico program to assembly language.
                • UseDef: Compute use-def information for the variables in a Pico program.
                  • ControlFlow: Compute the control flow graph for a Pico program.
                    • Visualize: Visualize Pico Control Flow Graphs.
                      • Uninit: Find unitialized variables in a Pico program.
                        • IDE: An Integrated Development Environment for Pico.
                          Examples Here is a -- not so simple-- Pico program that computes the factorial function:

                          begin declare input : natural,  
                                        output : natural,           
                                        repnr : natural,
                                        rep : natural;
                                input := 14;
                                output := 1;
                                while input - 1 do        
                                    rep := output;
                                    repnr := input;
                                    while repnr - 1 do
                                       output := output + rep;
                                       repnr := repnr - 1
                                    od;
                                    input := input - 1
                                od
                          end
                          
                          Notes:
                          • Pico programs do not have input/output statements, so we use variables for that purpose.
                          • Pico has no multiplication operator so we have to simulate it with repeated addition (yes, simplicity comes at a price!).
                          Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.