Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfjouault2013-12-18 12:23:55 -0500
committerfjouault2013-12-18 12:23:55 -0500
commit65b0671d4f5d0907029e1974c39e5dad4ffad691 (patch)
tree0de5dbf66d69f19c467de658fbb468031a3e5ec3 /syntaxes/SPL
downloadorg.eclipse.atl.tcs-65b0671d4f5d0907029e1974c39e5dad4ffad691.tar.gz
org.eclipse.atl.tcs-65b0671d4f5d0907029e1974c39e5dad4ffad691.tar.xz
org.eclipse.atl.tcs-65b0671d4f5d0907029e1974c39e5dad4ffad691.zip
initial commit of approved contribution (see bug 417707)
This version needs refactoring (notably package names) as well as porting to current version of ATL
Diffstat (limited to 'syntaxes/SPL')
-rw-r--r--syntaxes/SPL/.project22
-rw-r--r--syntaxes/SPL/Metamodel/SPL.ann2
-rw-r--r--syntaxes/SPL/Metamodel/SPL.km3534
-rw-r--r--syntaxes/SPL/Samples/SimpleForward.spl11
-rw-r--r--syntaxes/SPL/Syntax/SPL.tcs704
-rw-r--r--syntaxes/SPL/build.properties2
6 files changed, 1275 insertions, 0 deletions
diff --git a/syntaxes/SPL/.project b/syntaxes/SPL/.project
new file mode 100644
index 0000000..83910f2
--- /dev/null
+++ b/syntaxes/SPL/.project
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>SPL</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.m2m.atl.adt.builder.atlBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.gmt.tcs.builder.Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2m.atl.adt.builder.atlNature</nature>
+ </natures>
+</projectDescription>
diff --git a/syntaxes/SPL/Metamodel/SPL.ann b/syntaxes/SPL/Metamodel/SPL.ann
new file mode 100644
index 0000000..3542c32
--- /dev/null
+++ b/syntaxes/SPL/Metamodel/SPL.ann
@@ -0,0 +1,2 @@
+annotate SPL {
+} \ No newline at end of file
diff --git a/syntaxes/SPL/Metamodel/SPL.km3 b/syntaxes/SPL/Metamodel/SPL.km3
new file mode 100644
index 0000000..64f08ef
--- /dev/null
+++ b/syntaxes/SPL/Metamodel/SPL.km3
@@ -0,0 +1,534 @@
+-- @name SPL
+-- @version 1.0
+-- @domains
+-- @authors David Touzet (david.touzet@univ-nantes.fr)
+-- @date 2006/01/18
+-- @description This metamodel describes SPL (Session Processing Language). The goal of SPL is to ease the development of telephony services. SPL relies on a Service Logic Execution Environment for SIP (SIP-SLEE). SPL guaranties critical properties by introducing domain-specific concepts and semantic restrictions.
+-- @see http://phoenix.labri.fr/software/spl/
+package SPL {
+
+ abstract class LocatedElement {
+ attribute location : String;
+ attribute commentsBefore[*] ordered : String;
+ attribute commentsAfter[*] ordered : String;
+ }
+
+ class Program extends LocatedElement {
+ reference service container : Service;
+ }
+
+ class Service extends LocatedElement {
+ attribute name : String;
+ reference declarations[*] ordered container : Declaration;
+ reference sessions[*] ordered container : Session;
+ }
+
+-- @begin Sessions
+ abstract class Session extends LocatedElement {
+ }
+
+ class Registration extends Session {
+ reference declarations[*] ordered container : Declaration;
+ reference sessions[*] ordered container : Session;
+ }
+
+ class Dialog extends Session {
+ reference declarations[*] ordered container : Declaration;
+ reference methods[1-*] ordered container : Method;
+ }
+
+ class Event extends Session {
+ attribute eventId : String;
+ reference declarations[*] ordered container : Declaration;
+ reference methods[1-*] ordered container : Method;
+ }
+
+-- @begin Methods
+ class Method extends Session {
+ reference type container : TypeExpression;
+ attribute direction : Direction;
+ reference methodName container : MethodName;
+ reference arguments[*] ordered container : Argument;
+
+ -- Here instead of in SimpleMethod and ComposedMethod because TCS does not do left factoring yet
+ reference statements[1-*] ordered container : Statement;
+ reference branches[1-*] ordered container : Branch;
+ }
+
+-- class SimpleMethod extends Method {
+-- reference statements[1-*] ordered container : Statement;
+-- }
+--
+-- class ComposedMethod extends Method {
+-- reference branches[1-*] ordered container : DefaultBranch;
+-- }
+
+ -- no initExp allowed
+ class Argument extends VariableDeclaration {
+ }
+
+-- @begin Method Names
+ abstract class MethodName extends LocatedElement {
+ }
+
+ class SIPMethodName extends MethodName {
+ attribute name : SIPMethod;
+ }
+
+ class ControlMethodName extends MethodName {
+ attribute name : ControlMethod;
+ }
+-- @end Method Names
+-- @end Methods
+-- @end Sessions
+
+-- @begin Branches
+ class Branch extends LocatedElement {
+ reference statements[1-*] ordered container : Statement;
+ }
+
+ class DefaultBranch extends Branch {
+ }
+
+ class NamedBranch extends Branch {
+ attribute name[1-*] ordered : String;
+ }
+-- @end Branches
+
+
+-- @begin Types
+ abstract class TypeExpression extends LocatedElement {
+ }
+
+ class SimpleType extends TypeExpression {
+ attribute type : PrimitiveType;
+ }
+
+ class SequenceType extends TypeExpression {
+ attribute modifier[0-1] : Modifier;
+ reference type container : SimpleType;
+-- attribute type : PrimitiveType;
+ attribute size[0-1] : Integer;
+ }
+
+ class DefinedType extends TypeExpression {
+ attribute typeName : String;
+ }
+-- @end Types
+
+-- @begin Declarations
+ abstract class Declaration extends LocatedElement {
+ attribute name : String;
+ }
+
+ class VariableDeclaration extends Declaration {
+ reference type container : TypeExpression;
+ reference initExp[0-1] container : Expression;
+ }
+
+-- @begin FunctionDeclarations
+ abstract class FunctionDeclaration extends Declaration {
+ reference returnType container : TypeExpression;
+ reference arguments[*] ordered container : Argument;
+ }
+
+ class RemoteFunctionDeclaration extends FunctionDeclaration {
+ attribute functionLocation : FunctionLocation;
+ }
+
+ class LocalFunctionDeclaration extends FunctionDeclaration {
+ reference statements[1-*] ordered container : Statement;
+ }
+-- @end FunctionDeclarations
+
+-- @begin StructureDeclarations
+ class StructureDeclaration extends Declaration {
+ reference properties[1-*] ordered container : Argument;
+ }
+
+ class StructureProperty extends LocatedElement {
+ attribute name : String;
+ reference type container : TypeExpression;
+ }
+-- @end StructureDeclarations
+-- @end Declarations
+
+ class FunctionCall extends LocatedElement {
+ reference function : FunctionDeclaration;
+ reference parameters[*] ordered container : Expression;
+ }
+
+-- @begin Statements
+ abstract class Statement extends LocatedElement {
+ }
+
+ class CompoundStat extends Statement {
+ reference statements[1-*] container : Statement;
+ }
+
+ class SetStat extends Statement {
+ reference target container : Place;
+ reference setValue container : Expression;
+ }
+
+ class DeclarationStat extends Statement {
+ reference declaration container : Declaration;
+ }
+
+ class ReturnStat extends Statement {
+ reference returnedValue[0-1] container : Expression;
+ reference branch[0-1] : NamedBranch;
+ }
+
+ class IfStat extends Statement {
+ reference condition container : Expression;
+ reference thenStatement container : Statement;
+ reference elseStatement[0-1] container : Statement;
+ }
+
+ class WhenStat extends Statement {
+ reference idExp container : Variable;
+ reference whenHeaders[1-*] ordered container : WhenHeader;
+ reference statements[1-*] ordered container : Statement;
+ reference elseStatement[0-1] container : Statement;
+ }
+
+ class ForeachStat extends Statement {
+ reference iterator container : Iterator;
+ reference sequenceExp container : Expression;
+ reference statements[1-*] ordered container : Statement;
+ }
+
+ class Iterator extends VariableDeclaration {}
+
+ class SelectStat extends Statement {
+ reference matchedExp container : Expression;
+ reference selectCases[*] ordered container : SelectCase;
+ reference selectDefault[0-1] container : SelectDefault;
+ }
+
+ class FunctionCallStat extends Statement {
+ reference functionCall container : FunctionCall;
+ }
+
+ class ContinueStat extends Statement {
+ }
+
+ class BreakStat extends Statement {
+ }
+
+ class PushStat extends Statement {
+ reference target container : Place;
+ reference pushedValue container : Expression;
+ }
+-- @end Statements
+
+ -- no initExp allowed
+ class WhenHeader extends VariableDeclaration {
+ attribute headerId : String;
+ reference value[0-1] container : Constant;
+ }
+
+ abstract class SelectMember extends LocatedElement {
+ reference statements[*] ordered container : Statement;
+ }
+
+ class SelectDefault extends SelectMember {
+ }
+
+ class SelectCase extends SelectMember {
+ reference values[1-*] ordered container : Constant;
+ }
+
+-- @begin Expressions
+ abstract class Expression extends LocatedElement {
+ }
+
+ class ConstantExp extends Expression {
+ reference value container : Constant;
+ }
+
+ class OperatorExp extends Expression {
+ attribute opName : String;
+ reference leftExp container : Expression;
+ reference rightExp[0-1] container : Expression;
+ }
+
+ class ForwardExp extends Expression {
+ attribute isParallel : Boolean;
+ reference exp[0-1] container : Expression;
+ }
+
+ class WithExp extends Expression {
+ reference exp container : Expression;
+ reference msgFields[1-*] ordered container : MessageField;
+ }
+
+ class BlockExp extends Expression {
+ reference exp container : Expression;
+ }
+
+ class ReasonExp extends Expression {
+ }
+
+ class BODYExp extends Expression {
+ }
+
+ class RequestURIExp extends Expression {
+ }
+
+ class PopExp extends Expression {
+ reference source container : Place;
+ }
+
+ class FunctionCallExp extends Expression {
+ reference functionCall container : FunctionCall;
+ }
+
+-- @begin Places
+ abstract class Place extends Expression {
+ }
+
+ class SIPHeaderPlace extends Place {
+ attribute header : SIPHeader;
+ }
+
+ abstract class VariablePlace extends Place {
+ }
+
+ class PropertyCallPlace extends VariablePlace {
+ attribute propName : String;
+ reference source container : VariablePlace;
+ }
+
+ class Variable extends VariablePlace {
+ reference source : Declaration;
+ }
+-- @end Places
+
+ abstract class MessageField extends LocatedElement {
+ reference exp container : Expression;
+ }
+
+ class ReasonMessageField extends MessageField {
+ }
+
+ class HeadedMessageField extends MessageField {
+ attribute headerId : String;
+ }
+-- @end Expressions
+
+-- @begin Constants
+ abstract class Constant extends LocatedElement {
+ }
+
+ class BooleanConstant extends Constant {
+ attribute value : Boolean;
+ }
+
+ class IntegerConstant extends Constant {
+ attribute value : Integer;
+ }
+
+ class StringConstant extends Constant {
+ attribute value : String;
+ }
+
+ class URIConstant extends Constant {
+ attribute uri : String;
+ }
+
+ class SequenceConstant extends Constant {
+ reference values[*] ordered container : Constant;
+ }
+
+ class ResponseConstant extends Constant {
+ reference response container : Response;
+ }
+-- @end Constants
+
+-- @begin Responses
+ abstract class Response extends LocatedElement {
+ }
+
+ class SuccessResponse extends Response {
+ attribute successKind : SuccessKind;
+ }
+
+ class ErrorResponse extends Response {
+ }
+
+ class ClientErrorResponse extends ErrorResponse {
+ attribute errorKind[0-1] : ClientErrorKind;
+ }
+
+ class GlobalErrorResponse extends ErrorResponse {
+ attribute errorKind[0-1] : GlobalErrorKind;
+ }
+
+ class RedirectionErrorResponse extends ErrorResponse {
+ attribute errorKind[0-1] : RedirectionErrorKind;
+ }
+
+ class ServerErrorResponse extends ErrorResponse {
+ attribute errorKind[0-1] : ServerErrorKind;
+ }
+-- @end Responses
+}
+
+
+package Enum {
+
+ enumeration Direction {
+ literal inout;
+ literal in;
+ literal out;
+ }
+
+ enumeration SIPMethod {
+ literal ACK;
+ literal BYE;
+ literal CANCEL;
+ literal INVITE;
+ literal NOTIFY;
+ literal OPTIONS;
+ literal REACK;
+ literal REGISTER;
+ literal REINVITE;
+ literal REREGISTER;
+ literal RESUBSCRIBE;
+ literal SUBSCRIBE;
+ }
+
+ enumeration ControlMethod {
+ literal deploy;
+ literal undeploy;
+ literal uninvite;
+ literal unregister;
+ literal unsubscribe;
+ }
+
+ enumeration PrimitiveType {
+ literal void;
+ literal bool;
+ literal int;
+ literal request;
+ literal response;
+ literal string;
+ literal time;
+ literal uri;
+ }
+
+ enumeration Modifier {
+ literal LIFO;
+ literal FIFO;
+ }
+
+ enumeration FunctionLocation {
+ literal remote;
+ literal local;
+ }
+
+ enumeration SIPHeader {
+ literal CALL_ID;
+ literal CONTACT;
+ literal CSEQ;
+ literal EVENT;
+ literal FROM;
+ literal MAX_FORWARDS;
+ literal SUBSCRIPTION_STATE;
+ literal TO;
+ literal VIA;
+ }
+
+ enumeration SuccessKind {
+ literal OK;
+ literal ACCEPTED;
+ }
+
+ enumeration ClientErrorKind {
+ literal ADDRESS_INCOMPLETE;
+ literal AMBIGUOUS;
+ literal BAD_EXTENSION;
+ literal BAD_REQUEST;
+ literal BUSY_HERE;
+ literal CALL_OR_TRANSACTION_DOES_NOT_EXIST;
+ literal EXTENSION_REQUIRED;
+ literal FORBIDDEN;
+ literal GONE;
+ literal INTERVAL_TOO_BRIEF;
+ literal LOOP_DETECTED;
+ literal METHOD_NOT_ALLOWED;
+ literal NOT_ACCEPTABLE_HERE;
+ literal NOT_ACCEPTABLE;
+ literal NOT_FOUND;
+ literal PAYMENT_REQUIRED;
+ literal PROXY_AUTHENTICATION_REQUIRED;
+ literal REQUESTURI_TOO_LONG;
+ literal REQUEST_ENTITY_TOO_LARGE;
+ literal REQUEST_PENDING;
+ literal REQUEST_TERMINATED;
+ literal REQUEST_TIMEOUT;
+ literal TEMPORARILY_UNAVAILABLE;
+ literal TOO_MANY_HOPS;
+ literal UNAUTHORIZED;
+ literal UNDECIPHERABLE;
+ literal UNSUPPORTED_MEDIA_TYPE;
+ literal UNSUPPORTED_URI_SCHEME;
+ }
+
+ enumeration GlobalErrorKind {
+ literal BUSY_EVERYWHERE;
+ literal DECLINE;
+ literal DOES_NOT_EXIST_ANYWHERE;
+ literal NOT_ACCEPTABLE;
+ }
+
+ enumeration RedirectionErrorKind {
+ literal ALTERNATIVE_SERVICE;
+ literal MOVED_PERMANENTLY;
+ literal MOVED_TEMPORARILY;
+ literal MULTIPLE_CHOICES;
+ literal USE_PROXY;
+ }
+
+ enumeration ServerErrorKind {
+ literal BAD_GATEWAY;
+ literal MESSAGE_TOO_LARGE;
+ literal NOT_IMPLEMENTED;
+ literal SERVER_INTERNAL_ERROR;
+ literal SERVER_TIMEOUT;
+ literal SERVICE_UNAVAILABLE;
+ literal VERSION_NOT_SUPPORTED;
+ }
+
+-- enumeration UnaryOperator {
+-- literal "!";
+-- literal "-";
+-- }
+
+-- enumeration BinaryOperator {
+-- literal "+";
+-- literal "-";
+-- literal "*";
+-- literal "/";
+-- literal "<";
+-- literal ">";
+-- literal "==";
+-- literal "!=";
+-- literal "<=";
+-- literal ">=";
+-- literal "&&";
+-- literal "||";
+-- literal match;
+-- literal nomatch;
+-- }
+}
+
+
+package PrimitiveTypes {
+ datatype String;
+ datatype Integer;
+ datatype Boolean;
+}
+
diff --git a/syntaxes/SPL/Samples/SimpleForward.spl b/syntaxes/SPL/Samples/SimpleForward.spl
new file mode 100644
index 0000000..161b956
--- /dev/null
+++ b/syntaxes/SPL/Samples/SimpleForward.spl
@@ -0,0 +1,11 @@
+service SimpleForward {
+ processing {
+ uri us = 'sip:phoenix@barbade.enseirb.fr';
+
+ registration {
+ response incoming INVITE() {
+ return forward us;
+ }
+ }
+ }
+}
diff --git a/syntaxes/SPL/Syntax/SPL.tcs b/syntaxes/SPL/Syntax/SPL.tcs
new file mode 100644
index 0000000..a8e3c16
--- /dev/null
+++ b/syntaxes/SPL/Syntax/SPL.tcs
@@ -0,0 +1,704 @@
+syntax SPL(k = 0) {
+
+ primitiveTemplate identifier for String default using NAME:
+ value = "%token%";
+
+ primitiveTemplate stringSymbol for String using STRING:
+ value = "%token%",
+ serializer="'\'' + %value%.toCString() + '\''";
+
+ primitiveTemplate uriSymbol for String using URI:
+ value = "%token%",
+ serializer="'\'' + %value%.toCString() + '\''";
+
+ primitiveTemplate headerIdSymbol for String using HEADERID:
+ value = "%token%",
+ serializer="'\'' + %value%.toCString() + '\''";
+
+ primitiveTemplate integerSymbol for Integer default using INT:
+ value = "Integer.valueOf(%token%)";
+
+ template Program main
+ : service
+ ;
+
+ template Service context
+ : "service" name "{" [
+ [ "processing" "{" ] {indentIncr = 0, startNL = false, endNL = false, nbNL = 0} [
+ declarations
+ sessions
+ ] {nbNL = 2} "}"
+ ] "}"
+ ;
+
+-- @begin Sessions
+ template Session abstract;
+
+ template Registration context
+ : "registration" "{" [
+ declarations
+ sessions
+ ] {nbNL = 2} "}"
+ ;
+
+ template Dialog context
+ : "dialog" "{" [
+ declarations
+ methods
+ ] {nbNL = 2} "}"
+ ;
+
+ template Event
+ : "event" eventId
+ "{" [
+ declarations
+ methods
+ ] {nbNL = 2} "}"
+ ;
+
+-- @begin Methods
+ template Method context
+ : $methodHeader
+ "{" [
+ (isDefined(branches) ?
+ branches
+ :
+ statements
+ )
+ ] "}"
+ ;
+
+-- template SimpleMethod
+-- : $methodHeader "{" [
+-- statements
+-- ] "}"
+-- ;
+
+-- template ComposedMethod
+-- : $methodHeader "{" [
+-- branches
+-- ] "}"
+-- ;
+
+ function methodHeader(Method)
+ : type
+ (direction = #in ?
+ "incoming"
+ :
+ (direction = #out ?
+ "outgoing"
+ :
+ -- inout
+ )
+ )
+ methodName
+ "(" arguments{separator = ","} ")"
+ ;
+
+ template Argument addToContext
+ : type name
+ ;
+
+-- @begin Method Names
+ template MethodName abstract;
+
+ template SIPMethodName
+ : name
+ ;
+
+ template ControlMethodName
+ : name
+ ;
+-- @end Method Names
+-- @end Methods
+-- @end Sessions
+
+
+-- @begin Branches
+ template Branch abstract;
+
+ template DefaultBranch
+ : "branch" "default"
+ "{" statements "}"
+ ;
+
+ template NamedBranch
+ : "branch" name{separator = "|"}
+ "{" statements "}"
+ ;
+-- @end Branches
+
+-- @begin Declarations
+ template Declaration abstract;
+
+ template VariableDeclaration addToContext
+ : type name (isDefined(initExp) ? "=" initExp) ";"
+ ;
+
+-- @begin FunctionDeclarations
+ template FunctionDeclaration abstract;
+
+ template RemoteFunctionDeclaration addToContext
+ : functionLocation returnType name "(" arguments{separator = ","} ")" ";"
+ ;
+
+ template LocalFunctionDeclaration addToContext
+ : returnType name "(" arguments{separator = ","} ")" "{" [
+ statements
+ ] "}"
+ ;
+-- @end FunctionDeclarations
+
+-- @begin StructureDeclarations
+ template StructureDeclaration
+ : "type" name "{" [
+ properties
+ ] "}"
+ ;
+
+ template StructureProperty
+ : type name ";"
+ ;
+-- @end StructureDeclarations
+-- @end Declarations
+
+-- @begin Statements
+ template Statement abstract;
+
+ template CompoundStat
+ : "{" [ statements ] "}"
+ ;
+
+ template SetStat
+ : target "=" setValue ";"
+ ;
+
+ template DeclarationStat
+ : declaration
+ ;
+
+ template ReturnStat
+ : "return"
+ (isDefined(returnedValue) ? returnedValue)
+ (isDefined(branch) ? "branch" branch{refersTo = name, autoCreate = ifmissing})
+ ";"
+ ;
+
+ template IfStat
+ : "if" "(" condition ")" [
+ thenStatement
+ ]
+ (isDefined(elseStatement) ?
+ "else" [
+ elseStatement
+ ]
+ )
+ ;
+
+ template WhenStat context
+ : "when" idExp "(" whenHeaders{separator = ","} ")" "{" [
+ statements
+ ] "}"
+ (isDefined(elseStatement) ?
+ "else" [
+ elseStatement
+ ]
+ )
+ ;
+
+ template WhenHeader addToContext
+ : headerId{as = headerIdSymbol} type name (isDefined(value) ? value)
+ ;
+
+ template ForeachStat context
+ : "foreach" "(" iterator "in" sequenceExp ")" "{" [
+ statements
+ ] "}"
+ ;
+
+ template Iterator addToContext
+ : name
+ ;
+
+ template SelectStat
+ : "select" "(" matchedExp ")" "{" [
+ selectCases
+ (isDefined(selectDefault) ?
+ selectDefault
+ )
+ ] "}"
+ ;
+
+ template SelectCase
+ : "case" values{separator = "|"} ":" [ statements ]
+ ;
+
+ template SelectDefault
+ : "default" ":" [ statements ]
+ ;
+
+ template FunctionCallStat
+ : functionCall ";"
+ ;
+
+ template ContinueStat
+ : "continue" ";"
+ ;
+
+ template BreakStat
+ : "break" ";"
+ ;
+
+ template PushStat
+ : "push" target pushedValue ";"
+ ;
+-- @end Statements
+
+-- @begin Expressions
+ template Expression abstract operatored;
+
+ template ConstantExp
+ : value
+ ;
+
+ operatorTemplate OperatorExp(operators =
+-- opPoint opRarrow
+ opNot opMinus1
+ opStar opSlash
+ opPlus opMinus2
+ opEq opGt opLt opGe opLe opNe
+ opAnd opOr
+ opMatch opNoMatch
+ , source = leftExp, storeOpTo = opName, storeRightTo = rightExp);
+
+ -- must be nonPrimary because it finishes (or may finish) by an expression
+ template ForwardExp nonPrimary
+ : (isParallel ? "parallel") "forward" (isDefined(exp) ? exp)
+ ;
+
+ -- must be operatorTemplate because it is left recursive
+ operatorTemplate WithExp(operators = opWith, source = exp)
+ : "{" msgFields{separator = ","} "}"
+ ;
+
+ template MessageField abstract;
+
+ template ReasonMessageField
+ : "reason" "=" exp
+ ;
+
+ template HeadedMessageField
+ : headerId{as = headerIdSymbol} exp
+ ;
+
+ -- TODO: BlockExp?
+ template ReasonExp
+ : "reason"
+ ;
+
+ template BODYExp
+ : "BODY"
+ ;
+
+ template RequestURIExp
+ : "requestURI"
+ ;
+
+ template PopExp
+ : "pop" source
+ ;
+
+ template FunctionCallExp
+ : functionCall
+ ;
+
+ template FunctionCall
+ : function{refersTo = name} "(" parameters{separator = ","} ")"
+ ;
+
+ template Place abstract;
+
+ template SIPHeaderPlace
+ : header
+ ;
+
+ template VariablePlace abstract;
+
+ template Variable
+ : source{refersTo = name}
+ ;
+
+-- template PropertyCallPlace
+-- : -- TODO
+-- ;
+-- @end Expressions
+
+-- @begin Constants
+ template Constant abstract;
+
+ template BooleanConstant
+ : (value ? "true" : "false")
+ ;
+
+ template IntegerConstant
+ : value
+ ;
+
+ template StringConstant
+ : value{as = stringSymbol}
+ ;
+
+ template URIConstant
+ : uri{as = uriSymbol}
+ ;
+
+ template SequenceConstant
+ : "<" values{separator = ","} ">"
+ ;
+
+ template ResponseConstant
+ : response
+ ;
+-- @end Constants
+
+-- @begin Responses
+ template Response abstract;
+
+ template SuccessResponse abstract
+ : "/" <no_space> "SUCCESS"
+ (isDefined(successKind) ? <no_space> "/" <no_space> successKind)
+ ;
+
+ template ErrorResponse abstract
+ : "/" <no_space> "ERROR"
+ ;
+
+ template ClientErrorResponse
+ : "/" <no_space> "ERROR" <no_space> "/" <no_space> "CLIENT"
+ (isDefined(errorKind) ? <no_space> "/" <no_space> errorKind)
+ ;
+
+ template GlobalErrorResponse
+ : "/" <no_space> "ERROR" <no_space> "/" <no_space> "GLOBAL"
+ (isDefined(errorKind) ? <no_space> "/" <no_space> errorKind)
+ ;
+
+ template RedirectionErrorResponse
+ : "/" <no_space> "ERROR" <no_space> "/" <no_space> "REDIRECTION"
+ (isDefined(errorKind) ? <no_space> "/" <no_space> errorKind)
+ ;
+
+ template ServerErrorResponse
+ : "/" <no_space> "ERROR" <no_space> "/" <no_space> "SERVER"
+ (isDefined(errorKind) ? <no_space> "/" <no_space> errorKind)
+ ;
+-- @end Responses
+
+
+-- @begin Types
+ template TypeExpression abstract;
+
+ template SimpleType
+ : type
+ ;
+
+ template SequenceType
+ : (isDefined(modifier) ?
+ modifier
+ )
+ type "<" (isDefined(size) ? size) ">"
+ ;
+
+ enumerationTemplate Modifier auto
+ : #LIFO = "LIFO",
+ #FIFO = "FIFO"
+ ;
+-- @end Types
+
+ enumerationTemplate SIPMethod auto
+ : #ACK = "ACK",
+ #BYE = "BYE",
+ #CANCEL = "CANCEL",
+ #INVITE = "INVITE",
+ #NOTIFY = "NOTIFY",
+ #OPTIONS = "OPTIONS",
+ #REACK = "REACK",
+ #REGISTER = "REGISTER",
+ #REINVITE = "REINVITE",
+ #RESUBSCRIBE = "RESUBSCRIBE",
+ #SUBSCRIBE = "SUBSCRIBE"
+ ;
+
+ enumerationTemplate ControlMethod auto
+ : #deploy = "deploy",
+ #undeploy = "undeploy",
+ #uninvite = "uninvite",
+ #unregister = "unregister",
+ #unsubscribe = "unsubscribe"
+ ;
+
+ enumerationTemplate FunctionLocation auto
+ : #remote = "remote",
+ #local = "local"
+ ;
+
+ enumerationTemplate SuccessKind auto
+ : #OK = "OK",
+ #ACCEPTED = "ACCEPTED"
+ ;
+
+ enumerationTemplate ClientErrorKind auto
+ : #ADDRESS_INCOMPLETE = "ADDRESS_INCOMPLETE",
+ #AMBIGUOUS = "AMBIGUOUS",
+ #BAD_EXTENSION = "BAD_EXTENSION",
+ #BAD_REQUEST = "BAD_REQUEST",
+ #BUSY_HERE = "BUSY_HERE",
+ #CALL_OR_TRANSACTION_DOES_NOT_EXIST = "CALL_OR_TRANSACTION_DOES_NOT_EXIST",
+ #EXTENSION_REQUIRED = "EXTENSION_REQUIRED",
+ #FORBIDDEN = "FORBIDDEN",
+ #GONE = "GONE",
+ #INTERVAL_TOO_BRIEF = "INTERVAL_TOO_BRIEF",
+ #LOOP_DETECTED = "LOOP_DETECTED",
+ #METHOD_NOT_ALLOWED = "METHOD_NOT_ALLOWED",
+ #NOT_ACCEPTABLE_HERE = "NOT_ACCEPTABLE_HERE",
+ #NOT_ACCEPTABLE = "NOT_ACCEPTABLE",
+ #NOT_FOUND = "NOT_FOUND",
+ #PAYMENT_REQUIRED = "PAYMENT_REQUIRED",
+ #PROXY_AUTHENTICATION_REQUIRED = "PROXY_AUTHENTICATION_REQUIRED",
+ #REQUESTURI_TOO_LONG = "REQUESTURI_TOO_LONG",
+ #REQUEST_ENTITY_TOO_LARGE = "REQUEST_ENTITY_TOO_LARGE",
+ #REQUEST_PENDING = "REQUEST_PENDING",
+ #REQUEST_TERMINATED = "REQUEST_TERMINATED",
+ #REQUEST_TIMEOUT = "REQUEST_TIMEOUT",
+ #TEMPORARILY_UNAVAILABLE = "TEMPORARILY_UNAVAILABLE",
+ #TOO_MANY_HOPS = "TOO_MANY_HOPS",
+ #UNAUTHORIZED = "UNAUTHORIZED",
+ #UNDECIPHERABLE = "UNDECIPHERABLE",
+ #UNSUPPORTED_MEDIA_TYPE = "UNSUPPORTED_MEDIA_TYPE",
+ #UNSUPPORTED_URI_SCHEME = "UNSUPPORTED_URI_SCHEME"
+ ;
+
+ enumerationTemplate GlobalErrorKind auto
+ : #BUSY_EVERYWHERE = "BUSY_EVERYWHERE",
+ #DECLINE = "DECLINE",
+ #DOES_NOT_EXIST_ANYWHERE = "DOES_NOT_EXIST_ANYWHERE",
+ #NOT_ACCEPTABLE = "NOT_ACCEPTABLE"
+ ;
+
+ enumerationTemplate RedirectionErrorKind auto
+ : #ALTERNATIVE_SERVICE = "ALTERNATIVE_SERVICE",
+ #MOVED_PERMANENTLY = "MOVED_PERMANENTLY",
+ #MOVED_TEMPORARILY = "MOVED_TEMPORARILY",
+ #MULTIPLE_CHOICES = "MULTIPLE_CHOICES",
+ #USE_PROXY = "USE_PROXY"
+ ;
+
+ enumerationTemplate ServerErrorKind auto
+ : #BAD_GATEWAY = "BAD_GATEWAY",
+ #MESSAGE_TOO_LARGE = "MESSAGE_TOO_LARGE",
+ #NOT_IMPLEMENTED = "NOT_IMPLEMENTED",
+ #SERVER_INTERNAL_ERROR = "SERVER_INTERNAL_ERROR",
+ #SERVER_TIMEOUT = "SERVER_TIMEOUT",
+ #SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
+ #VERSION_NOT_SUPPORTED = "VERSION_NOT_SUPPORTED"
+ ;
+
+ enumerationTemplate SIPHeader auto
+ : #CALL_ID = "CALL_ID",
+ #CONTACT = "CONTACT",
+ #CSEQ = "CSEQ",
+ #EVENT = "EVENT",
+ #FROM = "FROM",
+ #MAX_FORWARDS = "MAX_FORWARDS",
+ #SUBSCRIPTION_STATE = "SUBSCRIPTION_STATE",
+ #TO = "TO",
+ #VIA = "VIA"
+ ;
+
+ enumerationTemplate PrimitiveType auto
+ : #void = "void",
+ #bool = "bool",
+ #int = "int",
+ #request = "request",
+ #response = "response",
+ #string = "string",
+ #time = "time",
+ #uri = "uri"
+ ;
+
+ symbols {
+ lsquare = "[";
+ rsquare = "]" : rightSpace;
+ excl = "!";
+ coma = "," : leftNone, rightSpace;
+ lparen = "(";
+ rparen = ")" : leftNone, rightSpace;
+ lcurly = "{" : leftSpace;
+ rcurly = "}" : leftNone, rightSpace;
+ semi = ";" : leftNone, rightSpace;
+ colon = ":" : leftNone, rightSpace;
+ colons = "::";
+ pipe = "|" : leftSpace, rightSpace;
+ sharp = "#" : leftSpace;
+ qmark = "?";
+
+ -- operator symbols
+ point = "." : leftNone;
+ rarrow = "->" : leftNone;
+ minus = "-" : leftSpace, rightSpace;
+ star = "*" : leftSpace, rightSpace;
+ slash = "/" : leftSpace, rightSpace;
+ plus = "+" : leftSpace, rightSpace;
+ eq = "=" : leftSpace, rightSpace;
+ eqeq = "==";
+ gt = ">" : leftSpace, rightSpace;
+ lt = "<" : leftSpace, rightSpace;
+ ge = ">=" : leftSpace, rightSpace;
+ le = "<=" : leftSpace, rightSpace;
+ ne = "!=" : leftSpace, rightSpace;
+ larrow = "<-" : leftSpace, rightSpace;
+ ampamp = "&&";
+ pipepipe = "||";
+ }
+
+ operators {
+ priority 0 { -- 0 is highest
+-- opPoint = point, 2;
+-- opRarrow = rarrow, 2;
+ opWith = "with", 2;
+ }
+
+ priority 1 {
+ opNot = excl, 1; -- no corresponding symbol => symbol is the keyword defined by the quoted string (which is also the name)
+ opMinus1 = minus, 1;
+ }
+
+ priority 2 {
+ opStar = star, 2;
+ opSlash = slash, 2;
+ }
+
+ priority 3 {
+ opPlus = plus, 2;
+ opMinus2 = minus, 2;
+ }
+
+ priority 4 {
+ opEq = eqeq, 2;
+ opGt = gt, 2;
+ opLt = lt, 2;
+ opGe = ge, 2;
+ opLe = le, 2;
+ opNe = ne, 2;
+ }
+
+ priority 5 {
+ opAnd = ampamp, 2;
+ opOr = pipepipe, 2;
+ }
+
+ priority 6 {
+ opMatch = "match", 2;
+ opNoMatch = "nomatch", 2;
+ }
+ }
+
+ token NAME : word(
+ start = [alpha] | "_",
+ part = [alnum] | "_"
+ , words = ("true" : BOOLEAN, "false" : BOOLEAN)
+ );
+ token COMMENT : endOfLine(start = "//") | multiLine(start = "/*", end = "*/");
+ token URI : multiLine(start = "\'", end = "\'");
+ token HEADERID : word(
+ start = "#",
+ part = [alnum] | "_" | "!" | "%" | "*" | "-" | "+" | "'" | "`" | "~",
+ end = ":"
+ );
+
+ lexer = "
+%options testLiterals = false;
+NL
+ : ( '\\r' '\\n'
+ | '\\n' '\\r' //Improbable
+ | '\\r'
+ | '\\n'
+ )
+ {newline();}
+ ;
+
+WS
+ : ( ' '
+ | '\\t'
+ )
+ ;
+
+%protected
+DIGIT
+ : '0'..'9'
+ ;
+
+INT
+ : (DIGIT)+
+ ;
+
+
+%protected
+ESC
+ : '\\\\'!
+ ( 'n' %v2{%setText(\"\\n\");}
+ | 'r' %v2{%setText(\"\\r\");}
+ | 't' %v2{%setText(\"\\t\");}
+ | 'b' %v2{%setText(\"\\b\");}
+ | 'f' %v2{%setText(\"\\f\");}
+ | '\"' %v2{%setText(\"\\\"\");}
+ | '\\.' %v2{%setText(\".\");} // SPL-specific
+ | '\\'' %v2{%setText(\"\\'\");}
+ | '\\\\' %v2{%setText(\"\\\\\");}
+ | (
+ ('0'..'3')
+ (
+%v2 options {
+%v2 warnWhenFollowAmbig = false;
+%v2 }
+ : ('0'..'7')
+ (
+%v2 options {
+%v2 warnWhenFollowAmbig = false;
+%v2 }
+ : '0'..'7'
+ )?
+ )?
+ | ('4'..'7')
+ (
+%v2 options {
+%v2 warnWhenFollowAmbig = false;
+%v2 }
+ : ('0'..'7')
+ )?
+ )
+ {
+%v2 String s = %getText;
+%v2 int i;
+%v2 int ret = 0;
+%v2 String ans;
+%v2 for (i=0; i<s.length(); ++i)
+%v2 ret = ret*8 + s.charAt(i) - '0';
+%v2 ans = String.valueOf((char) ret);
+%v2 %setText(ans);
+ }
+ )
+ ;
+
+STRING
+ : '\\\"'!
+ ( ESC
+ | '\\n' {newline();}
+ | ~('\\\\'|'\\\"'|'\\n')
+ )*
+ '\\\"'!
+%v3 {setText(ei.unescapeString(getText(), 1));}
+ ;
+ ";
+
+}
diff --git a/syntaxes/SPL/build.properties b/syntaxes/SPL/build.properties
new file mode 100644
index 0000000..c916421
--- /dev/null
+++ b/syntaxes/SPL/build.properties
@@ -0,0 +1,2 @@
+dsl.name=SPL
+dsl.ext=spl \ No newline at end of file

Back to the top