This repository implements a parser for the ARM Semantics Language (ASL), which is a domain-specific language for describing the semantics of ARM instructions [fn:asl-description]. The parser is written in Java using ANTLR; the Java tool dumps the parsed AST in an s-expression format. The included Haskell library (asl-parser) parses the s-expression format into a native Haskell ADT.
The ASL is extracted from the official XML specifications from ARM [fn:arm-specs] using a set of tools [fn:mra_tools] developed by Alastair Reid.
To download, extract, and parse the ASL specification, simply run:
make all
This performs the following steps:
- Downloads and extracts the XML specifications from ARM into the
xml
subdirectory. - Uses mra_tools to parse the XML specifications into ASL. This creates
arch.asl
,arch_instrs.asl
,regs.asl
andsupport.asl
in theasl
subdirectory. - Uses the ANTLR parser to parse these into an s-expression format. This creates
arm_defs.sexpr
,arm_instrs.sexpr
,arm_regs.sexpr
andsupport.expr
in theasl-parsed
subdirectory.
Currently, this repository only implements a library parsing the generated s-expression files. Client code can use the library to process ASL. See the module Language.ASL.Parser
and the functions parseAslDefs
, parseAslInsts
and parseAslRegs
. The mra_tools produce three files of interest: arch.asl
, arch_instrs.asl
and regs.asl
. The first contains definitions of functions used to implement instruction semantics. The second contains the definitions of the semantics of each instruction in the architecture. The third contains definitions for the registers used in other two. Additionally mra_tools provides a collection of reference implementations for implementation-defined functions in the ASL specification. These are concatenated together in support.asl
.
The cabal target `asl-parser` builds the parser library.
cabal v2-build asl-parser
[fn:mra_tools] https://github.com/alastairreid/mra_tools [fn:asl-description] https://alastairreid.github.io/dissecting-ARM-MRA/ [fn:arm-specs] https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools