CBuilder


This module has been removed in release 14.0.0. Use Script module instead.

This class builds tokens into expressions.

You can find more information in comments below.

/*
    USAGE: 
        I. Scenario: 
            1. CBuilder builder; // Create builder 
            2. builder.SetJson(); // Set all required options to process needed language/format 
            3. CExpression *e{ builder.Build(tokens) }; // Process 
        II. Scenario: 
            1. CBuilder builder; // Create builder 
            2. Use AddXXX() methods to set required settings 
            3. CExpression *e{ builder.Build(tokens) }; // Process 
    NOTE: 
        All block operators should be added despite of the same can be added to procedure/subscript/array operators 
    */
    class CBuilder
    {
    public:
        ERROR_INFO getLastError() const; // Return last detected error code 
        bool isBuildMath() const; // Whether to build or not to build mathematical expressions(arrange according to operators' precedence) 
        Tokens::size_type getBlockOperatorCount() const; // Return count of block added operators(for example, "(" in "build.Build()") 
        int getBlockOperator(const Tokens::size_type index) const; // Return block operator by index 
        Tokens::size_type getProcedureOperatorCount() const; // Return count of procedure call added operators(for example, "(" in "build.Build()") 
        int getProcedureOperator(const Tokens::size_type index) const; // Return procedure call operator by index 
        Tokens::size_type getSubscriptOperatorCount() const; // Return count of subscription start added operators(for example, "[" in "a[i]") 
        int getSubscriptOperator(const Tokens::size_type index) const; // Return subscription start operator by index 
        Tokens::size_type getComplexSeparatorCount() const; // Return count of operators which separate complex identifier parts(for example, "." in "build.Build()") 
        int getComplexSeparator(const Tokens::size_type index) const; // Return complex operator by index 
        Tokens::size_type getArrayOperatorCount() const; // Return count of array start added operators(for example, "[" in "[2, 3]") 
        int getArrayOperator(const Tokens::size_type index) const; // Return array start operator by index 
        Tokens::size_type getRangeSeparatorCount() const; // Return count of operators used ad separators in ranges(for example, ".." in "[-5 .. 5]") 
        int getRangeSeparator(const Tokens::size_type index) const; // Return range operator by index 
        Tokens::size_type getProcedureSeparatorCount() const; // Return count of added operators used as arguments separators in functions(for example, "," in "sum(2, 3)") 
        int getProcedureSeparator(const Tokens::size_type index) const; // Return procedure separator by index 
        Tokens::size_type getSubscriptSeparatorCount() const; // Return count of added operators used as arguments separators in subscripts(for example, "," in "a[i, j]") 
        int getSubscriptSeparator(const Tokens::size_type index) const; // Return sbscript separator by index 
        Tokens::size_type getArraySeparatorCount() const; // Return count of added operators used as separators for array values(for example, "," in "[1, 2, 3]") 
        int getArraySeparator(const Tokens::size_type index) const; // Return array separator by index 
    
        bool setBuildMath(const bool value); // Set whether to build or not to build mathematical expressions 
    
        // Manage block operators 
        bool AddBlockOperator(const int value);
        bool DeleteBlockOperator(const Tokens::size_type index);
        bool DeleteBlockOperators();
    
        // Manage procedure operators 
        bool AddProcedureOperator(const int value);
        bool DeleteProcedureOperator(const Tokens::size_type index);
        bool DeleteProcedureOperators();
    
        // Manage subscript operators 
        bool AddSubscriptOperator(const int value);
        bool DeleteSubscriptOperator(const Tokens::size_type index);
        bool DeleteSubscriptOperators();
    
        // Manage complex values separators 
        bool AddComplexSeparator(const int value);
        bool DeleteComplexSeparator(const Tokens::size_type index);
        bool DeleteComplexSeparators();
    
        // Manage array operators 
        bool AddArrayOperator(const int value);
        bool DeleteArrayOperator(const Tokens::size_type index);
        bool DeleteArrayOperators();
    
        // Manage range separators 
        bool AddRangeSeparator(const int value);
        bool DeleteRangeSeparator(const Tokens::size_type index);
        bool DeleteRangeSeparators();
    
        // Manage procedure argument seperators 
        bool AddProcedureSeparator(const int value);
        bool DeleteProcedureSeparator(const Tokens::size_type index);
        bool DeleteProcedureSeparators();
    
        // Manage subscript argument separators 
        bool AddSubscriptSeparator(const int value);
        bool DeleteSubscriptSeparator(const Tokens::size_type index);
        bool DeleteSubscriptSeparators();
    
        // Manage array value separators 
        bool AddArraySeparator(const int value);
        bool DeleteArraySeparator(const Tokens::size_type index);
        bool DeleteArraySeparators();
    
        CBuilder(); // Constructor 
    
        void SetPascal(); // Set all settings to build Pascal-like language expression 
        void SetCpp(); // Set all settings to build C++-like language expression 
        void SetAsm(); // Set all settings to build Assembler-like language expression 
        void SetPhp(); // Set all settings to build PHP-like language expression 
        void SetJson(); // Set all settings to build JSON format expression 
    
        CExpression *Build(const Tokens &tokens); // Build expression. Return nullptr if build is not possible. Otherwise check last error(via getLastError method) to check if built successfully 
    };
Namespace: nitisa::scripting
Include: Nitisa/Modules/Scripting/Builder.h