LabComm.ast 1.2 KB
Newer Older
Anders Nilsson's avatar
Anders Nilsson committed
1
2
Program ::= Decl*;

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//TODO: Add signatures to the abstract grammar, so that
//they can be extended and refined by more than one aspect.
//sketch:
Signature		::= SignatureList FlatSignatureList:SignatureList; 
SignatureList		::= SignatureLine*;
abstract SignatureLine 	::= <Indent:int> <Comment:String>; 
abstract DataSignatureLine : SignatureLine;
ByteArraySignatureLine : DataSignatureLine ::= <Data:byte[]>;
IntSignatureLine : DataSignatureLine ::= <Data:int>;
StringSignatureLine : DataSignatureLine ::= <Data:String>;
TypeRefSignatureLine   	: SignatureLine ::= Decl;


//abstract Decl ::= Type <Name:String>;
// the signature list be defined as  a non-terminal attribute:
abstract Decl ::= Type <Name:String> /Signature/;
Anders Nilsson's avatar
Anders Nilsson committed
19
20
21
22
23
24
25
TypeDecl : Decl;
SampleDecl : Decl;

Field ::= Type <Name:String>;

abstract Type;
VoidType          : Type;
26
SampleRefType     : Type;
Anders Nilsson's avatar
Anders Nilsson committed
27
28
29
30
PrimType          : Type ::= <Name:String> <Token:int>;
UserType          : Type ::= <Name:String>;
StructType        : Type ::= Field*;
ParseArrayType    : Type ::= Type Dim*;
31
abstract ArrayType :Type ::= Type Exp*;
Anders Nilsson's avatar
Anders Nilsson committed
32
33
34
35
36
37
38
39
VariableArrayType : ArrayType;
FixedArrayType    : ArrayType;

Dim ::= Exp*;

abstract Exp;
IntegerLiteral : Exp ::= <Value:String>;
VariableSize : Exp;