We will specify the context free grammar of DMS using Extended Backus-Naur Form (EBNF). Specifically:
Note
Because there are multiple ways to express the device models in Scala, the specification described here should not be treated as prescriptive. Instead, the specification is provided as a guideline for people that are not familiar with Scala (but familiar with Java) in order for the model to be accepted by the DMS Model Extractor; some possible variations are described on how one can express a model differently.
In addition, for the grammar productions, we describe DML implementation classes and API; when referring to such classes/packages, we use dml as a shorthand for the edu.ksu.cis.santos.mdcf.dml package. Similarly, we use dms as a shorthand for the edu.ksu.cis.santos.mdcf.dms package. The DML Abstract Syntax Tree (AST) Java classes are defined in the dml.ast package with associated AST constructor methods in dml.ast.Ast (and its weak version dml.ast.Ast.Weak), symbol table API in dml.symbol.SymbolTable, visitor API in dml.ast.IVisitor and dml.ast.AbstractVisitor, and XML de/serialization API in dml.serialization.XStreamer. The dms.ModelExtractor Scala object provides methods to extract DML AST from DMS models.
Furthermore, we also describe AST well-formedness throughout the discussion of various parts of DMS; some of the well-formedness are enforced by the Scala compiler, while some additional ones are enforced by the dms.ModelExtractor, and some are (to be) done after the extraction process.
All method parameters in all the DML API are non-null by default; these are declared in the respective package infos (dml.ast, dml.serialization, dml.symbol). In addition, all DML methods return non-null values.
All DML objects are immutable (object state changes may occur but not observable through the API). Each AST node class stores its children in public final fields, which are non-null; fields whose type is List store immutable List values. In addition, each node class inherits from the dml.ast.AstNode, which provides a children method that returns an array of the node’s children; the returned array can be mutated but it does not affect the AST node.
Calling the toString method on an AST object or a dml.symbol.SymbolTable object produces a Java and Scala code as a String that, when compiled under the appropriate import context and executed, builds a structurally and behaviorally equivalent object.