C++ Dialect

LA.Docs
March 1st, 2016

The C++ Dialect


C++ Syntax Definitions

Program -> [UsesClause]
[DeclSection]...
CompoundStmt
UsesClause -> ’#’ INCLUDE (String/,)...
DeclSection -> ConstSection
            -> ProcedureDeclSection
            -> VarStmt ’;’
ConstSection -> ’#’ DEFINE ConstantDecl
ConstantDecl -> Ident Expression
VarStmt -> Ident Ident [Array] [InitValue] /’,’...
ArrayDef -> ’[’ ArrayDim/’,’... ’]’
ArrayDim -> Expression
InitValue -> ’=’ Expression
Expression -> SimpleExpression [RelOp SimpleExpression]...
SimpleExpression -> [’-’] Term [AddOp Term]...
Term -> Factor [MulOp Factor]...
Factor -> Designator
       -> UnsignedNumber
       -> String
       -> ’(’ Expression ’)’
       -> ’!’ Factor
       -> ’[’ SetConstructor ’]’
       -> NewOperator
SetConstructor -> SetNode/’,’...
SetNode -> Expression [’..’ Expression]
NewOperator -> NEW Designator
RelOp -> ’>’ -> ’<’ -> ’<=’ -> ’>=’ -> ’!=’ -> ’==’ -> IN -> IS
AddOp -> ’+’ -> ’-’ -> ’||’ -> ’^’
MulOp -> ’’ -> ’/’ -> ’%’ -> ’&&’ -> ’<<’ -> ’>>’
Designator -> [’&’] Ident [’.’ Ident | ’[’ ExprList ’]’ | ’(’ ExprList’)’]...
ExprList -> Expression/’,’...
Statement -> [SimpleStatement ’;’ | StructStmt | EmptyStmt]
EmptyStmt -> ’;’
StmtList -> (Statement...)
SimpleStatement -> DeleteStmt
                -> AssignStmt
                -> VarStmt
                -> CallStmt
                -> ReturnStmt
                -> (BREAK | CONTINUE | EXIT)
DeleteStmt -> DELETE Designator
AssignStmt -> Designator [’+’|’-’|’’|’/’]’=’ Expression
CallStmt -> Designator [’+’’+’|’-’’-’]
ReturnStmt -> RETURN [Expression]
StructStmt -> CompoundStmt
           -> ConditionalStmt
           -> LoopStmt
           -> TryStmt
CompoundStmt -> ’{’ [StmtList] ’}’
ConditionalStmt -> IfStmt
-> CaseStmt
IfStmt -> IF ’(’ Expression ’)’ Statement [ELSE Statement]
CaseStmt -> SWITCH ’(’ Expression ’)’ ’{’ (CaseSelector)...
                   [DEFAULT ’:’ Statement] ’}’
CaseSelector -> CASE SetConstructor ’:’ Statement
LoopStmt -> RepeatStmt
         -> WhileStmt
         -> ForStmt
RepeatStmt -> DO Statement [’;’] WHILE ’(’ Expression ’)’ ’;’
WhileStmt -> WHILE ’(’ Expression ’)’ Statement
ForStmt -> FOR ’(’ ForStmtItem ’;’ Expression ’;’ ForStmtItem ’)’
Statement
ForStmtItem -> AssignStmt
            -> VarStmt
            -> CallStmt
            -> Empty
TryStmt -> TRY CompoundStmt (FINALLY | EXCEPT) CompoundStmt
FunctionDecl -> FunctionHeading CompoundStmt
FunctionHeading -> Ident Ident [FormalParameters]
FormalParameters -> ’(’ [FormalParam/’;’...] ’)’
FormalParam -> TypeIdent ([’&’] Ident [InitValue]/’,’)...