Skip to main content

module lang::php::ast::AbstractSyntax

rascal-0.40.17
php-analysis-0.2.4

Usage

import lang::php::ast::AbstractSyntax;

Source code

http://github.com/cwi-swat/php-analysis/blob/main/src/main/rascal/lang/php/ast/AbstractSyntax.rsc

data OptionExpr

data OptionExpr  
= someExpr(Expr expr)
| noExpr()
;

data OptionName

data OptionName  
= someName(Name name)
| noName()
;

data OptionElse

data OptionElse  
= someElse(Else e)
| noElse()
;

data ActualParameter

data ActualParameter (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= actualParameter(Expr expr, bool byRef, bool isPacked, OptionName paramName)
| variadicPlaceholder()
;

data Const

data Const (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= const(str name, Expr constValue)
;

data ArrayElement

data ArrayElement (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= arrayElement(OptionExpr key, Expr val, bool byRef, bool unpack)
| emptyElement()
;

data Name

data Name (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= name(str name)
;

data NameOrExpr

data NameOrExpr (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= name(Name name)
| expr(Expr expr)
;

data ClassName

data ClassName  
= explicitClassName(Name name)
| computedClassName(Expr expr)
| anonymousClassDef(Stmt stmt)
;

data CastType

data CastType (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= \int()
| \bool()
| float()
| string()
| array()
| object()
| unset()
;

data ClosureUse

data ClosureUse (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= closureUse(Expr varName, bool byRef)
;

data IncludeType

data IncludeType (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= include()
| includeOnce()
| require()
| requireOnce()
;

data PHPType

data PHPType  
= nullableType(PHPType nestedType)
| regularType(Name typeName)
| unionType(list[PHPType] types)
| intersectionType(list[PHPType] types)
| noType()
;

data Expr

data Expr (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= array(list[ArrayElement] items, bool usesBracketNotation)
| fetchArrayDim(Expr var, OptionExpr dim)
| fetchClassConst(NameOrExpr className, str constantName)
| assign(Expr assignTo, Expr assignExpr)
| assignWOp(Expr assignTo, Expr assignExpr, Op operation)
| listAssign(list[OptionExpr] assignsTo, Expr assignExpr)
| refAssign(Expr assignTo, Expr assignExpr)
| binaryOperation(Expr left, Expr right, Op operation)
| unaryOperation(Expr operand, Op operation)
| new(ClassName classToInstantiate, list[ActualParameter] parameters)
| cast(CastType castType, Expr expr)
| clone(Expr expr)
| closure(list[Stmt] statements, list[Param] params, list[ClosureUse] closureUses, bool byRef, bool static, PHPType returnType, list[AttributeGroup] attributeGroups)
| fetchConst(Name name)
| empty(Expr expr)
| suppress(Expr expr)
| eval(Expr expr)
| exit(OptionExpr exitExpr, bool isExit)
| call(NameOrExpr funName, list[ActualParameter] parameters)
| methodCall(Expr target, NameOrExpr methodName, list[ActualParameter] parameters, bool nullsafe)
| staticCall(NameOrExpr staticTarget, NameOrExpr methodName, list[ActualParameter] parameters)
| include(Expr expr, IncludeType includeType)
| instanceOf(Expr expr, NameOrExpr toCompare)
| isSet(list[Expr] exprs)
| print(Expr expr)
| propertyFetch(Expr target, NameOrExpr propertyName, bool nullsafe)
| shellExec(list[Expr] parts)
| ternary(Expr cond, OptionExpr ifBranch, Expr elseBranch)
| staticPropertyFetch(NameOrExpr className, NameOrExpr propertyName)
| scalar(Scalar scalarVal)
| var(NameOrExpr varName)
| yield(OptionExpr keyExpr, OptionExpr valueExpr)
| yieldFrom(Expr fromExpr)
| listExpr(list[ArrayElement] listExprs)
| arrowFunction(bool isStatic, bool byRef, list[Param] params, PHPType returnType, Expr body, list[AttributeGroup] attributeGroups)
| \throw(Expr expr)
| match(Expr cond, list[MatchArm] arms)
;

data Op

data Op (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= bitwiseAnd()
| bitwiseOr()
| bitwiseXor()
| concat()
| div()
| minus()
| \mod()
| mul()
| plus()
| rightShift()
| leftShift()
| booleanAnd()
| booleanOr()
| booleanNot()
| bitwiseNot()
| gt()
| geq()
| logicalAnd()
| logicalOr()
| logicalXor()
| notEqual()
| notIdentical()
| postDec()
| preDec()
| postInc()
| preInc()
| lt()
| leq()
| unaryPlus()
| unaryMinus()
| equal()
| identical()
| pow()
| coalesce()
| spaceship()
;

data Param

data Param (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= param(str paramName, OptionExpr paramDefault,bool byRef,bool isVariadic, PHPType paramType, set[Modifier] modifiers, list[AttributeGroup] attributeGroups)
;

data Scalar

data Scalar (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="", str actualValue="") 
= classConstant()
| dirConstant()
| fileConstant()
| funcConstant()
| lineConstant()
| methodConstant()
| namespaceConstant()
| traitConstant()
| float(real realVal)
| integer(int intVal)
| string(str strVal)
| encapsed(list[Expr] parts)
;

data Stmt

data Stmt (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= \break(OptionExpr breakExpr)
| classDef(ClassDef classDef)
| const(list[Const] consts)
| \continue(OptionExpr continueExpr)
| declare(list[Declaration] decls, list[Stmt] body)
| do(Expr cond, list[Stmt] body)
| echo(list[Expr] exprs)
| exprstmt(Expr expr)
| \for(list[Expr] inits, list[Expr] conds, list[Expr] exprs, list[Stmt] body)
| foreach(Expr arrayExpr, OptionExpr keyvar, bool byRef, Expr asVar, list[Stmt] body)
| function(str name, bool byRef, list[Param] params, list[Stmt] body, PHPType returnType, list[AttributeGroup] attributeGroups)
| global(list[Expr] exprs)
| goto(str label)
| haltCompiler(str remainingText)
| \if(Expr cond, list[Stmt] body, list[ElseIf] elseIfs, OptionElse elseClause)
| inlineHTML(str htmlText)
| interfaceDef(InterfaceDef interfaceDef)
| traitDef(TraitDef traitDef)
| label(str labelName)
| namespace(OptionName nsName, list[Stmt] body)
| namespaceHeader(Name namespaceName)
| \return(OptionExpr returnExpr)
| static(list[StaticVar] vars)
| \switch(Expr cond, list[Case] cases)
| tryCatch(list[Stmt] body, list[Catch] catches)
| tryCatchFinally(list[Stmt] body, list[Catch] catches, list[Stmt] finallyBody)
| unset(list[Expr] unsetVars)
| useStmt(list[Use] uses, OptionName prefixName, UseType useType)
| \while(Expr cond, list[Stmt] body)
| emptyStmt()
| block(list[Stmt] body)
| enumDef(EnumDef enumDef)
;

data UseType

data UseType  
= useTypeUnknown()
| useTypeNormal()
| useTypeFunction()
| useTypeConst()
;

data Declaration

data Declaration (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= declaration(str key, Expr val)
;

data Catch

data Catch (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= \catch(list[Name] xtypes, str varName, list[Stmt] body)
;

data Case

data Case (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= \case(OptionExpr cond, list[Stmt] body)
;

data ElseIf

data ElseIf (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= elseIf(Expr cond, list[Stmt] body)
;

data Else

data Else (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= \else(list[Stmt] body)
;

data Use

data Use (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= use(Name importName, OptionName asName, UseType useType)
;

data ClassItem

data ClassItem (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= property(set[Modifier] modifiers, list[Property] prop, PHPType propType, list[AttributeGroup] attributeGroups)
| constCI(list[Const] consts, set[Modifier] modifiers, list[AttributeGroup] attributeGroups)
| method(str name, set[Modifier] modifiers, bool byRef, list[Param] params, list[Stmt] body, PHPType returnType, list[AttributeGroup] attributeGroups)
| traitUse(list[Name] traits, list[Adaptation] adaptations)
| enumCase(str caseName, OptionExpr caseExpr, list[AttributeGroup] attributeGroups)
;

data Adaptation

data Adaptation  
= traitAlias(OptionName traitName, str methName, set[Modifier] newModifiers, OptionName newName)
| traitPrecedence(OptionName traitName, str methName, set[Name] insteadOf)
;

data Property

data Property (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= property(str propertyName, OptionExpr defaultValue)
;

data Modifier

data Modifier (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= \public()
| \private()
| protected()
| static()
| abstract()
| final()
| readonly()
;

data ClassDef

data ClassDef (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= class(str className, set[Modifier] modifiers, OptionName extends, list[Name] implements, list[ClassItem] members, list[AttributeGroup] attributeGroups)
| anonymousClass(OptionName extends, list[Name] implements, list[ClassItem] members, list[AttributeGroup] attributeGroups)
;

data InterfaceDef

data InterfaceDef (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= interface(str interfaceName, list[Name] extends, list[ClassItem] members, list[AttributeGroup] attributeGroups)
;

data TraitDef

data TraitDef (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= trait(str traitName, list[ClassItem] members, list[AttributeGroup] attributeGroups)
;

data StaticVar

data StaticVar (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= staticVar(str name, OptionExpr defaultValue)
;

data MatchArm

data MatchArm  
= matchArm(list[Expr] conds, Expr body)
;

data EnumDef

data EnumDef (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= enum(str enumName, PHPType scalarType, list[Name] implements, list[ClassItem] members, list[AttributeGroup] attributeGroups)
;

data Attribute

data Attribute (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= attribute(Name attrName, list[ActualParameter] args)
;

data AttributeGroup

data AttributeGroup  
= attributeGroup(list[Attribute] attributes)
;

data Script

data Script (loc at=|unknown:///|, loc decl=|unknown:///|, str id="", loc scope=|unknown:///|, str phpdoc="") 
= script(list[Stmt] body)
| errscript(str err)
;

alias PhpParams

lrel[loc decl, set[loc] typeHints, bool isRequired, bool byRef]