Paul Evans > Tangence > Tangence::Compiler::Parser

Download:
Tangence-0.20.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.20   Source  

NAME ^

Tangence::Compiler::Parser - parse Tangence interface definition files

DESCRIPTION ^

This subclass of Parser::MGC parses a Tangence interface definition and returns a metadata tree.

GRAMMAR ^

The top level of an interface definition file contains include directives and class and struct definitions.

include

An include directive imports the definitions from another file, named relative to the current file.

 include "filename.tan"

class

A class definition defines the set of methods, events and properties defined by a named class.

 class N {
    ...
 }

The contents of the class block will be a list of method, event, prop and isa declarations.

struct

A struct definition defines the list of fields contained within a named structure type.

 struct N {
    ...
 }

The contents of the struct block will be a list of field declarations.

method

A method declaration defines one method in the class, giving its name (N) and types of its arguments and and return (T).

 method N(T, T, ...) -> T;

event

An event declaration defines one event raised by the class, giving its name (N) and types of its arguments (T).

 event N(T, T, ...);

prop

A prop declaration defines one property supported by the class, giving its name (N), dimension (D) and type (T). It may be declared as a smashed property.

 [smashed] prop N = D of T;

Scalar properties may omit the scalar of, by supplying just the type

 [smashed] prop N = T;

isa

An isa declaration declares a superclass of the class, by its name (C)

 isa C;

Types

The following basic type names are recognised

 bool int str obj any
 s8 s16 s32 s64 u8 u16 u32 u64

Aggregate types may be formed of any type (T) by

 list(T) dict(T)

SUBCLASS METHODS ^

If this class is subclassed, the following methods may be overridden to customise the behaviour. They allow the subclass to return different objects in the syntax tree.

$class = $parser->make_class( name => $name )

Return a new instance of Tangence::Meta::Class to go in a package. The parser will call define on it.

$struct = $parser->make_struct( name => $name )

Return a new instance of Tangence::Meta::Struct to go in a package. The parser will call define on it.

$method = $parser->make_method( %args )

$event = $parser->make_event( %args )

$property = $parser->make_property( %args )

Return a new instance of Tangence::Meta::Method, Tangence::Meta::Event or Tangence::Meta::Property to go in a class.

$argument = $parser->make_argument( %args )

Return a new instance of Tangence::Meta::Argument to use for a method or event argument.

$field = $parser->make_field( %args )

Return a new instance of Tangence::Meta::Field to use for a structure type.

$type = $parser->make_type( $primitive_name )

$type = $parser->make_type( $aggregate_name => $member_type )

Return an instance of Tangence::Meta::Type representing the given primitive or aggregate type name. An implementation is allowed to use singleton objects and return identical objects for the same primitive name or aggregate and member type.

AUTHOR ^

Paul Evans <leonerd@leonerd.org.uk>

syntax highlighting: