Skip to content

diku-dk/sml-aplparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sml-aplparse CI

This Standard ML library implements an APL parser.

Overview of MLB files

  • lib/github.com/diku-dk/sml-aplparse/aplparse.mlb:

Use of the package

This library is set up to work well with the SML package manager smlpkg. To use the package, in the root of your project directory, execute the command:

$ smlpkg add github.com/diku-dk/sml-aplparse

This command will add a requirement (a line) to the sml.pkg file in your project directory (and create the file, if there is no file sml.pkg already).

To download the library into the directory lib/github.com/diku-dk/sml-aplparse (along with other necessary libraries), execute the command:

$ smlpkg sync

You can now reference the mlb-file using relative paths from within your project's mlb-files.

Notice that you can choose either to treat the downloaded package as part of your own project sources (vendoring) or you can add the sml.pkg file to your project sources and make the smlpkg sync command part of your build process.

Try it!

The parser compiles with either MLton or MLKit.

Now write

$ smlpkg sync

The implementation builds on the unicode library available at https://github.com/diku-dk/sml-unicode, but smlpkg will arrange for this library to be fetched and installed automatically.

Then simply write make test in your shell.

To use the MLKit as a compiler, write instead:

$ MLCOMP=mlkit make clean test

Example

The APL program

diff  {1¯1}
signal  {¯505050×(diff 0,)÷0.01+}

parses into the following abstract syntax tree (pretty printed):

[Assign(diff,Lam(App2(Drop,1,App2(Sub,Omega,App2(Rot,-1,Omega))))),
 Assign(signal,Lam(App2(Max,-50,
                     App2(Min,50,
                       App2(Times,50,
                         App2(Div,
                           App1(diff,App2(Cat,0,Omega)),
                           App2(Add,0.01,Omega)
                         )
                       )
                     )
                   )
                  )
       )
]

The test parses the APL programs in the tests directory.

The library is used for apltail, a compiler and interpreter for APL, based on a typed array intermediate language [1]. The compiler compiles APL to C.

Limitations

Todo: improved error handling. Although position information is now maintained in the parser, not all parser errors are reported with relevant position information.

Authors

Copyright (c) 2015-2021 Martin Elsman, Martin Dybdal, University of Copenhagen.

References

[1] Martin Elsman and Martin Dybdal. Compiling a Subset of APL Into a Typed Intermediate Language. In ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming (ARRAY'14). Edinburgh, UK. June, 2014. pdf, bibtex.

About

Standard ML APL Parser Library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published