[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

input/output in ASF+SDF generated environments




Hi Jawad,


Subject: input/output from the keyboard/screen


=> I want some ideas about the use of imput/output from the keyboard/screen 
=> in a program with the environment ASF+SDF.

First of all, the ASF+SDF formalism does not feature I/O at all. When you
want to use I/O, there are two ways to do it:
- the "dirty" way is to use hybrid functions.
- the "neat" way is to use 'SEAL' (Semantics-directed Environment Adaptation
  Language).

Pro's and con's:
^^^^^^^^^^^^^^^
Hybrid functions are fast and allow you to use any functionality. However,
you need to program them in LeLisp (or in another language and interface
to it from LeLisp).
This clearly messes up your semantics, from a formal point of view that is.

SEAL, developed by yours truely, is a user-interface definition language
dedicated to the ASF+SDF Meta-environment. It is used to add user-interface
items (buttons, menus, etc.) to default windows of GSE (ASF+SDF editor)
instances. Each such item is connected to a _condition_ and an _action_.
The condition states when the item should be enabled or disabled.
The action is a list of SEAL statements. There are statements for:
- moving a focus
- assigning (sub)trees to variables. These trees may be the result of a
  functioncall in ASF+SDF.
- display variables in a GSE window, i.e., do output
- asking input from the user.
EXAMPLE
Suppose you have a typechecking function 'tc' defined in a module TC as follows
	tc(PROGRAM)	-> ERRORS
Let the name of your language be L.
You may connect this function to a button by writing the following SEAL script
that displays the errors in a window called Errors as follows:
	Configuration for language L is
	button Typecheck		%%button label is 'Typecheck'
	when focus root is PROGRAM      %%the whole tree should be of sort ...
	enable
	  Program := focus root;	%%assign the whole tree to variable
	  Error-list := TC : tc(Program); %%call 'tc' in module 'TC'
	  create("Errors", Error-list)  %%display the var. 'Error-list'
	doc: "Typecheck a program"

   The pro's of using SEAL are that _no_ programminmg is required. SEAL 
features a compiler that compiles the script to LeLisp source code, which is 
automatically loaded when the language 'L' is used.
   The con's of using SEAL are that you have to compile the script using a
_separate_ ASF+SDF Meta-environment. The SEAL compiler is completely written in 
ASF+SDF so starting the compiler takes quite some time.
I _very_ recently (two weeks ago) made a version of SEAL that can be used
while your original environment keeps running(!). This version of SEAL is
completely in binary format. Adapting an environment now takes no more than
a couple of seconds and there is no need to use a separate ASF+SDF Meta-env.
However, this version is not even distributed within the project.....

If you are interested in using SEAL, read my paper "Connecting semantic tools
to a syntax-directed user-interface". ftp available at cwi.nl.


Take care, Wilco.