rem: =   simpleType.alias()
add: =   simpleType
context:         definition(pascal_grammar const& /*self*/)        {            #ifdef BOOST_SPIRIT_DEBUG            debug(); // define the debug names            #endif            //-----------------------------------------------------------------            // KEYWORDS            //-----------------------------------------------------------------            keywords =                "in", "div", "mod", "and", "or", "not", "nil", "goto",                "if", "then", "else", "case", "while", "repeat", "until",                "for", "do", "to", "downto", "with", "program", "label",                "const", "type", "char", "boolean", "integer", "real",                "packed", "array", "of", "record", "end", "set", "file",                "var", "procedure", "function", "begin";            //-----------------------------------------------------------------            // OPERATORS            //-----------------------------------------------------------------            chlit<>     PLUS('+');            chlit<>     MINUS('-');            chlit<>     STAR('*');            chlit<>     SLASH('/');            strlit<>    ASSIGN(":=");            chlit<>     COMMA(',');            chlit<>     SEMI(';');            chlit<>     COLON(':');            chlit<>     EQUAL('=');            strlit<>    NOT_EQUAL("<>");            chlit<>     LT('<');            strlit<>    LE("<=");            strlit<>    GE(">=");            chlit<>     GT('>');            chlit<>     LPAREN('(');            chlit<>     RPAREN(')');            chlit<>     LBRACK('[');            chlit<>     RBRACK(']');            chlit<>     POINTER('^');            chlit<>     DOT('.');            strlit<>    DOTDOT("..");            //-----------------------------------------------------------------            // TOKENS            //-----------------------------------------------------------------            typedef inhibit_case<strlit<> > token_t;            token_t IN_         = nocase_d["in"];            token_t DIV         = nocase_d["div"];            token_t MOD         = nocase_d["mod"];            token_t AND         = nocase_d["and"];            token_t OR          = nocase_d["or"];            token_t NOT         = nocase_d["not"];            token_t NIL         = nocase_d["nil"];            token_t GOTO        = nocase_d["goto"];            token_t IF          = nocase_d["if"];            token_t THEN        = nocase_d["then"];            token_t ELSE        = nocase_d["else"];            token_t CASE        = nocase_d["case"];            token_t WHILE       = nocase_d["while"];            token_t REPEAT      = nocase_d["repeat"];            token_t UNTIL       = nocase_d["until"];            token_t FOR         = nocase_d["for"];            token_t DO          = nocase_d["do"];            token_t TO          = nocase_d["to"];            token_t DOWNTO      = nocase_d["downto"];            token_t WITH        = nocase_d["with"];            token_t PROGRAM     = nocase_d["program"];            token_t LABEL       = nocase_d["label"];            token_t CONST_      = nocase_d["const"];            token_t TYPE        = nocase_d["type"];            token_t CHAR        = nocase_d["char"];            token_t BOOLEAN     = nocase_d["boolean"];            token_t INTEGER     = nocase_d["integer"];            token_t REAL        = nocase_d["real"];            token_t PACKED_     = nocase_d["packed"];            token_t ARRAY       = nocase_d["array"];            token_t OF          = nocase_d["of"];            token_t RECORD      = nocase_d["record"];            token_t END         = nocase_d["end"];            token_t SET         = nocase_d["set"];            token_t FILE        = nocase_d["file"];            token_t VAR         = nocase_d["var"];            token_t PROCEDURE   = nocase_d["procedure"];            token_t FUNCTION    = nocase_d["function"];            token_t BEGIN       = nocase_d["begin"];            //-----------------------------------------------------------------            //  Start grammar definition            //-----------------------------------------------------------------            identifier                = nocase_d[                    lexeme_d[                        (alpha_p >> *(alnum_p | '_'))                        - (keywords >> anychar_p - (alnum_p | '_'))                    ]                ];            string_literal                = lexeme_d[ chlit<>('\'') >>                   +( strlit<>("\'\'") | anychar_p-chlit<>('\'') ) >>                   chlit<>('\'') ];            program                =   programHeading >>                    block >>                    DOT                ;            programHeading                =   PROGRAM >> identifier >>                    LPAREN >> fileIdentifier                    >> *( COMMA >> fileIdentifier ) >> RPAREN >>                    SEMI                ;            fileIdentifier                =   identifier.alias()                ;            block                =  *(   labelDeclarationPart                    |   constantDefinitionPart                    |   typeDefinitionPart                    |   variableDeclarationPart                    |   procedureAndFunctionDeclarationPart                    ) >>                    statementPart                ;            labelDeclarationPart                =   LABEL >> label >> *( COMMA >> label ) >> SEMI                ;            label                =   unsignedInteger.alias()                ;            constantDefinitionPart                =   CONST_ >> constantDefinition                    >> *( SEMI >> constantDefinition ) >> SEMI                ;            constantDefinition                =   identifier >> EQUAL >> constant                ;            constant                =   unsignedNumber                |   sign >> unsignedNumber                |   constantIdentifier                |   sign >> constantIdentifier                |   string_literal                ;            unsignedNumber                =   lexeme_d[uint_p                >>  !('.' >> uint_p)                >>  !(nocase_d['e'] >> (ch_p('+') | '-') >> uint_p)]                ;            unsignedInteger                =   uint_p                ;            unsignedReal                =   ureal_p                ;            sign                =   PLUS | MINUS                ;            constantIdentifier                =   identifier.alias()                ;            typeDefinitionPart                =   TYPE >> typeDefinition                    >> *( SEMI >> typeDefinition ) >> SEMI                ;            typeDefinition                =   identifier >> EQUAL >> type                ;            type                =   simpleType                |   structuredType                |   pointerType                ;            simpleType                =   scalarType                |   subrangeType                |   typeIdentifier                ;            scalarType                =   LPAREN >> identifier                    >> *( COMMA >> identifier ) >> RPAREN                ;            subrangeType                =   constant >> DOTDOT >> constant                ;            typeIdentifier                =   identifier                |   CHAR                |   BOOLEAN                |   INTEGER                |   REAL                ;            structuredType                =   ( PACKED_                    | empty                    ) >>                    unpackedStructuredType                ;            unpackedStructuredType                =   arrayType                |   recordType                |   setType                |   fileType                ;            arrayType                =   ARRAY >> LBRACK >> indexType                    >> *( COMMA >> indexType ) >> RBRACK >> OF >>                    componentType                ;            indexType                =   simpleType.alias()                ;            componentType                =   type.alias()                ;            recordType                =   RECORD >> fieldList >> END                ;            fieldList                =   fixedPart >>                    ( SEMI >> variantPart                    | empty                    )                |   variantPart                ;            fixedPart                =   recordSection >> *( SEMI >> recordSection )                ;            recordSection                =   fieldIdentifier                    >> *( COMMA >> fieldIdentifier ) >> COLON >> type                |   empty                ;            variantPart                =   CASE >> tagField >> typeIdentifier >> OF >>                    variant >> *( SEMI >> variant )                ;            tagField                =   fieldIdentifier >> COLON                |   empty                ;            variant                =   caseLabelList >> COLON >> LPAREN >> fieldList >> RPAREN                |   empty                ;            caseLabelList                =   caseLabel >> *( COMMA >> caseLabel )                ;            caseLabel                =   constant.alias()                ;            setType                =   SET >> OF >> baseType                ;            baseType                =   simpleType.alias()                ;            fileType                =   FILE >> OF >> type                ;            pointerType                =   POINTER >> typeIdentifier                ;            variableDeclarationPart                =   VAR >> variableDeclaration                    >> *( SEMI >> variableDeclaration ) >> SEMI                ;            variableDeclaration                =   identifier >> *( COMMA >> identifier ) >> COLON >> type                ;            procedureAndFunctionDeclarationPart                =   procedureOrFunctionDeclaration >> SEMI                ;            procedureOrFunctionDeclaration                =   procedureDeclaration                |   functionDeclaration                ;            procedureDeclaration                =   procedureHeading                    >> block                ;            procedureHeading                =   PROCEDURE >> identifier >> parameterList >> SEMI                ;            parameterList                =   empty                |   LPAREN >> formalParameterSection                    >> *( SEMI >> formalParameterSection ) >> RPAREN                ;            formalParameterSection                =   parameterGroup                |   VAR >> parameterGroup                |   FUNCTION >> parameterGroup                |   PROCEDURE >> identifier >> *( COMMA >> identifier )                ;            parameterGroup                =   identifier >> *( COMMA >> identifier ) >> COLON >> typeIdentifier                ;            functionDeclaration                =   functionHeading >>                    block                ;            functionHeading                =   FUNCTION >> identifier >> parameterList                    >> COLON >> resultType >> SEMI                ;            resultType                =   typeIdentifier.alias()                ;            statementPart                =   compoundStatement.alias()                ;            statement                =   ( label >> COLON                    | empty                    ) >>                    unlabelledStatement                ;            unlabelledStatement                =   structuredStatement                |   simpleStatement                ;            simpleStatement                =   assignmentStatement                |   procedureStatement                |   gotoStatement                |   emptyStatement                ;            assignmentStatement                =   variable >> ASSIGN >> expression                |   functionIdentifier >> ASSIGN >> expression                ;            variable                =   componentVariable                |   referencedVariable                |   entireVariable                ;            entireVariable                =   variableIdentifier.alias()                ;            variableIdentifier                =   identifier.alias()                ;            componentVariable                =   indexedVariable                |   fieldDesignator                |   fileBuffer                ;            indexedVariable                =   arrayVariable >> LBRACK                    >> expression >> *( COMMA >> expression) >> RBRACK                ;            arrayVariable                =   identifier.alias()                ;            fieldDesignator                =   recordVariable >> DOT >> fieldIdentifier                ;            recordVariable                =   identifier.alias()                ;            fieldIdentifier                =   identifier.alias()                ;            fileBuffer                =   fileVariable >> POINTER                ;            fileVariable                =   identifier.alias()                ;            referencedVariable                =   pointerVariable >> POINTER                ;            pointerVariable                =   identifier.alias()                ;            expression                =   simpleExpression >>                    ( relationalOperator >> simpleExpression                    | empty                    )                ;            relationalOperator                =   EQUAL | NOT_EQUAL | GE | LE | LT | GT | IN_                ;            simpleExpression                =   ( sign                    | empty                    ) >>                    term >> *( addingOperator >> term )                ;            addingOperator                =   PLUS | MINUS | OR                ;            term                =   factor >> *( multiplyingOperator >> factor )                ;            multiplyingOperator                =   STAR | SLASH | DIV | MOD | AND                ;            factor                =   LPAREN >> expression >> RPAREN                |   set                |   longest_d[                        variable                    |   unsignedConstant                    |   functionDesignator                ]                |   NOT >> factor                ;            unsignedConstant                =   unsignedNumber                |   string_literal                |   constantIdentifier                |   NIL                ;            functionDesignator                =   functionIdentifier >>                    ( LPAREN >> actualParameter                        >> *( COMMA >> actualParameter ) >> RPAREN                    | empty                    )                ;            functionIdentifier                =   identifier.alias()                ;            set                =   LBRACK >> elementList >> RBRACK                ;            elementList                =   element >> *( COMMA >> element )                |   empty                ;            element                =   expression >>                    ( DOTDOT >> expression                    | empty                    )                ;            procedureStatement                =   procedureIdentifier >>                    ( LPAREN >> actualParameter                        >> *( COMMA >> actualParameter ) >> RPAREN                    | empty                    )                ;            procedureIdentifier                =   identifier.alias()                ;            actualParameter                =   expression                |   variable                |   procedureIdentifier                |   functionIdentifier                ;            gotoStatement                =   GOTO >> label                ;            emptyStatement                =   empty.alias()                ;            empty                =   epsilon_p                ;            structuredStatement                =   compoundStatement                |   conditionalStatement                |   repetetiveStatement                |   withStatement                ;            compoundStatement                =   BEGIN >>                    statement >> *( SEMI >> statement ) >>                    END                ;            conditionalStatement                =   ifStatement                |   caseStatement                ;            ifStatement                =   IF >> expression >> THEN >> statement >>                    ( ELSE >> statement                    | empty                    )                ;            caseStatement                =   CASE >> expression >> OF >>                    caseListElement >> *( SEMI >> caseListElement ) >>                    END                ;            caseListElement                =   caseLabelList >> COLON >> statement                |   empty                ;            repetetiveStatement                =   whileStatement                |   repeatStatement                |   forStatement                ;            whileStatement                =   WHILE >> expression >> DO >>                    statement                ;            repeatStatement                =   REPEAT >>                    statement >> *( SEMI >> statement ) >>                    UNTIL >> expression                ;            forStatement                =   FOR >> controlVariable >> ASSIGN >> forList >> DO >>                    statement                ;            forList                =   initialValue >> ( TO | DOWNTO ) >> finalValue                ;            controlVariable                =   identifier.alias()                ;            initialValue                =   expression.alias()                ;            finalValue                =   expression.alias()                ;            withStatement                =   WITH >> recordVariableList >> DO >>                    statement                ;            recordVariableList                =   recordVariable >> *( COMMA >> recordVariable )                ;            //-----------------------------------------------------------------            //  End grammar definition            //-----------------------------------------------------------------        }