Jump to content

junjieg

Members
  • Content Count

    1
  • Joined

  • Last visited

About junjieg

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Per 1.0a release the grammar of range in c++ syntax is implemented without template, however the examples showed us that sometimes we can use it with template, sometimes we can use it without template, are the examples which using with template incorrect or not? see below for details: range header definition in annex C.36, define it without template =========================================================== C.36 File pss/range.h #pragma once #include <vector> #include "pss/detail/rangeBase.h" namespace pss { class Lower { public: }; // Used to specify a range that is bounded // by the domain minimum const Lower lower; class Upper { public: }; // Used to specify a range that is bounded // by the domain maximum const Upper upper; /// Declare domain of a numeric scalar attribute class range : public detail::RangeBase { public: /// Declare a range of values range (const detail::AlgebExpr& lhs, const detail::AlgebExpr& rhs); range (const Lower& lhs, const detail::AlgebExpr& rhs); range (const detail::AlgebExpr& lhs, const Upper& rhs); /// Declare a single value range (const detail::AlgebExpr& value); /// Copy constructor range ( const range& a_range); /// Function chaining to declare another range of values range& operator() (const detail::AlgebExpr& lhs, const detail::AlgebExpr& rhs); /// Function chaining to declare another single value range& operator() (const detail::AlgebExpr& value); }; // class range }; // namespace pss =========================================================== examples without template 8.1.3 Examples =========================================================== 8.1.3 Examples The DSL and C++ scalar data examples are shown in-line within this section. DSL: bit [5] in [0..31] b; C++: attr b { "b", width(5), range (0,31) }; Declare an unsigned variable that is 5-bits wide and has the valid values 1, 2, and 4. DSL: bit [5] in [1,2,4] c; C++: attr<bit> c { "c", width(5), range (1)(2)(4) }; Declare an unsigned variable that is 5-bits wide and has the valid values 0..10. DSL: bit [5] in[..10] b; // 0 <= b <= 10 C++: attr<bit> b {"b", width(5), range(lower,10)}; Declare an unsigned variable that is 5-bits wide and has the valid values 10..31. DSL: bit [5] in [10..] b; // 10 <= b <= 31 C++: attr<bit> b {"b", width(5), range(10, upper)}; =========================================================== examples with template 8.3.3 Examples =========================================================== DSL: config_modes_e in [MODE_A..MODE_C] mode_ac; C++: rand_attr<config_modes_e> mode_ac{"mode_ac",range<config_modes_e>(MODE_A,MODE_C)}; Declare an enum of type config_modes_e with values MODE_A or MODE_C. DSL: config_modes_e in [MODE_A, MODE_C] mode_ac; C++: rand_attr<config_modes_e> mode_ac{"mode_ac",range<config_modes_e>(MODE_A)(MODE_C)}; Declare an enum of type config_modes_e with values UNKNOWN, MODE_A, or MODE_B. DSL: config_modes_e in [..MODE_B] mode_ub; C++: rand_attr<config_modes_e> mode_ub{"mode_ub",range<config_modes_e>(lower,MODE_B)}; Declare an enum of type config_modes_e with values MODE_B, MODE_C, or MODE_D. DSL: config_modes_e in [MODE_B..] mode_bd; C++: rand_attr<config_modes_e> mode_bd{"mode_bd",range<config_modes_e>(MODE_B, upper)}; =========================================================== examples with template 8.4.3 Examples =========================================================== DSL: rand string in ["Hello", "Hallo", "Ni Hao"] hello_s; C++: rand_attr<std::string> hello_s{"hello_s",range<std::string>("Hello")("Hallo")("Ni Hao")}; ===========================================================
×
×
  • Create New...