Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module metac.parser.ast.nodes;
- import metac.parser.ast : IAstNode, TAstNode;
- import metac.parser.ast.rules;
- import std.container.array : Array;
- import std.traits : getSymbolsByUDA;
- import std.meta : AliasSeq;
- alias AllNodes = getSymbolsByUDA!(metac.parser.ast.nodes, IAstNode);
- interface IIntegerLiteral : IAstNode {
- }
- @IAstNode:
- class HexIntegerLiteral : TAstNode!HexIntegerLiteral, IIntegerLiteral {
- alias syntax = Seq!(Str!"0x", Plus!Hex, NotAt!Alnum);
- @Pop string digits;
- }
- class BinIntegerLiteral : TAstNode!BinIntegerLiteral, IIntegerLiteral {
- alias syntax = Seq!(Str!"0b", Plus!Binary);
- @Pop string digits;
- }
- class OctIntegerLiteral : TAstNode!OctIntegerLiteral, IIntegerLiteral {
- alias syntax = Seq!(Str!"0", Plus!Octal);
- @Pop string digits;
- }
- class DecIntegerLiteral : TAstNode!DecIntegerLiteral, IIntegerLiteral {
- alias syntax = Plus!Digit;
- @Pop string digits;
- }
- class IntegerLiteral : TAstNode!IntegerLiteral {
- alias syntax = Sor!(HexIntegerLiteral, BinIntegerLiteral,
- OctIntegerLiteral, DecIntegerLiteral);
- @Pop IIntegerLiteral digits;
- }
- class BasicType : TAstNode!BasicType {
- alias syntax = SorString!("void", "half", "float", "double", "byte", "ubyte",
- "short", "ushort", "int", "uint", "long", "ulong", "char", "wchar", "dchar");
- @Pop string name;
- }
- class Identifier : TAstNode!Identifier {
- alias syntax = Seq!(Alpha, Star!(Alnum));
- @Pop string identifier;
- }
- class QualifiedIdentifier : TAstNode!QualifiedIdentifier {
- alias syntax = Seq!(Identifier, Star!(Sep, Str!".", Sep, Identifier));
- @Pop Array!Identifier identifiers;
- }
- class Type : TAstNode!Type {
- alias syntax = Sor!(BasicType, QualifiedIdentifier);
- @Pop IAstNode element;
- }
- class VariableDeclaration : TAstNode!VariableDeclaration {
- alias syntax = Seq!(Type, Space, Identifier);
- @Pop Type type;
- @Pop Identifier identifier;
- }
- class UnitHeader : TAstNode!UnitHeader {
- alias syntax = Seq!(Str!"unit", Space, QualifiedIdentifier, Sep, Str!";");
- @Pop QualifiedIdentifier identifier;
- }
- class UnitBody : TAstNode!UnitBody {
- alias syntax = Star!(Sep, IntegerLiteral);
- @Pop Array!IAstNode children;
- }
- class Unit : TAstNode!Unit {
- alias syntax = Seq!(BoF, Sep, UnitHeader, Sep, UnitBody, Sep, EoF);
- @Pop UnitHeader header;
- @Pop UnitBody body;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement