Name

parse-stratego — parses a Stratego source file

Synopsis

parse-stratego [-I dir | --Include dir] [--syntax syn] [--default-syntax syn] [--asfix] [--desugaring on|off] [--assimilation on|off] [] [-i file | --input file] [-o file | --outputfile] [-S | --silent] [--verbose level] [--k level | --keep level] [-h | -? | --help] [--about] [--version]

Description

The parse-stratego utility is used to parse Stratego source files. The result of the parsing is an abstract syntax tree of the input program, output as a binary ATerm.

Stratego source code may include modules from other directories. Specifying the search path is done by the -I option. A parse error will occur if all referenced modules cannot be found. By default the standard library is automatically included in the search path.

Stratego source code can be extended with embedded languages having their own concrete syntax, making Stratego a syntactically extensible language. When the source code contains a Stratego program extended in this way, parse-stratego must be told which syntax to use when parsing the source code. This is the task of the --syntax and --default-syntax options.

As a part of embedding languages in Stratego, the new language constructs can be translated into Stratego library functions and code. This is called assimilation, and is controlled by the --assimilation switch.

Options

Module and Syntax Options

-I dir, --Include dir

Add dir to the module search path.

--syntax syn

Use syntax syn.

--default-syn syn

Use syntax syn as the default syntax.

--asfix

Use the AsFix format.

--desugaring on | off

Toggle desugaring on/off. Default is off

--assimilation on | off

Toggle assimilation on/off. Default is on.

Common Input/Output Options

-i file

The input term given by the file name file.

In the absence of the -i option, input will be read from stdin.

-o file

The output will be written to the file given by the file name file.

In the absence of the -o option, output will be written to stdout.

-b

The output will be written in the binary (BAF) ATerm format.

ATerms in the BAF format require a lot less space than ones in the TAF format, but the Java ATerm library does not currently support baf ATerms. ATerms in the baf format is the preferred format of exchange between Stratego tools.

Common Debugging Options

--about

See --version.

-h, -?, --help

Display usage information.

--keep int

Keep intermediate results produced by the internal stages in the pretty-printing process. This is only useful for debugging. A high value of int indicates increased eagerness for keeping intermediate results.

Default setting is 0, indicating that no intermediates will be kept.

-S, --silent

Silent execution. Same as --verbose 0.

--verbose int

Set verbosity level to numerical value int. The higher the number, the more information about pp-aterm's inner workings are printed.

Alternatively, int can be set to either of the following verbosity levels, given in increasing order of verbosity: emergency, alert, critical, error, warning, notice, info, debug, vomit.

--version

Displays the tool name and version.

Example

Given the file myunit.str given below.

module myunit
imports
  sunit
signature
  constructors
    F: A -> F
    A: A
      
strategies
      
  main = 
    test-suite(!"foo",
      apply-test(
        !"all-test1a"
      , all(id)
      , !F(A)
      , !F(A)
      )
    )
    

We can obtain the abstract syntax tree for this program as an ATerm by issuing the following command:

$ parse-stratego -i myunit.str -o tree.trm

The result will be the following term:

Module(
  "parse-stratego-example"
, [ Imports([Import("sunit")])
  , Signature(
      [ Constructors(
          [ OpDecl(
              "F"
            , FunType([ConstType(SortNoArgs("A"))], ConstType(SortNoArgs("F")))
            )
          , OpDecl("A", ConstType(SortNoArgs("A")))
          ]
        )
      ]
    )
  , Strategies(
      [ SDefNoArgs(
          "main"
        , Call(
            SVar("test-suite")
          , [ Build(NoAnnoList(Str("\"foo\"")))
            , Call(
                SVar("apply-test")
              , [ Build(NoAnnoList(Str("\"all-test1a\"")))
                , All(Id)
                , Build(NoAnnoList(Op("F", [Var("A")])))
                , Build(NoAnnoList(Op("F", [Var("A")])))
                ]
              )
            ]
          )
        )
      ]
    )
  ]
)
    

Reporting Bugs

Please report bugs to

Copyright

Copyright (C) 2002-2005 Eelco Visser

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.