项目作者: diku-dk

项目描述 :
Standard ML APL Parser Library
高级语言: Standard ML
项目地址: git://github.com/diku-dk/sml-aplparse.git
创建时间: 2021-01-11T16:35:16Z
项目社区:https://github.com/diku-dk/sml-aplparse

开源协议:MIT License

下载


sml-aplparse CI

This Standard ML library implements an APL parser.

Overview of MLB files

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

    • signature REGION
    • signature APL_PARSE
    • signature PARSE_COMB
    • structure Region :> REGION
    • structure AplParse :> APL_PARSE
    • structure ParseComb :> PARSE_COMB

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:

  1. $ 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:

  1. $ 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

  1. $ 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:

  1. $ MLCOMP=mlkit make clean test

Example

The APL program

  1. diff {1↓⍵−¯1⌽⍵}
  2. signal 505050×(diff 0,⍵)÷0.01+⍵}

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

  1. [Assign(diff,Lam(App2(Drop,1,App2(Sub,Omega,App2(Rot,-1,Omega))))),
  2. Assign(signal,Lam(App2(Max,-50,
  3. App2(Min,50,
  4. App2(Times,50,
  5. App2(Div,
  6. App1(diff,App2(Cat,0,Omega)),
  7. App2(Add,0.01,Omega)
  8. )
  9. )
  10. )
  11. )
  12. )
  13. )
  14. ]

The test parses the APL programs in the
tests directory.

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.