"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/plugins/cpp_ref_cplusplus_com.lua" (12 May 2020, 8441 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "cpp_ref_cplusplus_com.lua": 3.53_vs_3.54.

    1 --[[
    2 Sample plugin file for highlight 3.9
    3 ]]
    4 
    5 Description="Add cplusplus.com reference links to HTML, LaTeX, RTF and ODT output of C and C++ code"
    6 
    7 Categories = {"c++", "html", "rtf", "latex", "odt" }
    8 
    9 -- optional parameter: syntax description
   10 function syntaxUpdate(desc)
   11 
   12   if desc~="C and C++" then
   13     return
   14   end
   15 
   16   function Set (list)
   17     local set = {}
   18     for _, l in ipairs(list) do set[l] = true end
   19       return set
   20   end
   21 
   22   string_items = Set {"string" ,  "u16string", "u32string"}
   23 
   24   stl_items = Set {"array", "bitset", "deque", "forward_list", "list",
   25     "map", "multimap", "multiset", "priority_queue", "queue", "set", "stack",
   26     "unordered_map", "unordered_multimap", "unordered_multiset", "unordered_set",
   27     "vector" }
   28 
   29   algorithm_items = Set {"adjacent_find", "all_of", "any_of","binary_search", "copy",
   30     "copy_backward", "copy_if", "copy_n", "count", "count_if", "equal", "equal_range", "fill", "fill_n",
   31     "find", "find_end", "find_first_of", "find_if", "find_if_not", "for_each", "generate",
   32     "generate_n", "includes", "inplace_merge", "is_heap", "is_heap_until", "is_partitioned",
   33     "is_permutation", "is_sorted", "is_sorted_until","iter_swap",
   34     "lexicographical_compare", "lower_bound", "make_heap", "max", "max_element",
   35     "merge", "min", "minmax", "minmax_element", "min_element", "mismatch", "move", "move-backward",
   36     "next_permutation", "none_of", "nth_element",
   37     "partial_sort", "partial_sort_copy", "partition", "partition_copy", "partition_point", "pop_heap",
   38     "prev_permutation", "push_heap", "random_shuffle", "remove", "remove_copy",
   39     "remove_copy_if", "remove_if", "replace", "replace_copy", "replace_copy_if",
   40     "replace_if", "reverse", "reverse_copy", "rotate", "rotate_copy", "search",
   41     "search_n", "set_difference", "set_intersection", "set_symmetric_difference",
   42     "set_union", "shuffle", "sort", "sort_heap", "stable_partition", "stable_sort", "swap",
   43     "swap_ranges", "transform", "unique", "unique_copy", "upper_bound" }
   44 
   45   clib_items = Set {"cassert", "cctype", "cerrno", "cfloat", "ciso646",
   46     "climits", "clocale", "cmath", "csetjmp", "csignal", "cstdarg", "cstddef",
   47     "cstdio ", "cstdlib", "cstring", "ctime"}
   48 
   49   iostream_items=Set {
   50     "filebuf", "fstream", "ifstream", "ios", "iostream", "ios_base", "istream",
   51     "istringstream", "ofstream", "ostream", "ostringstream", "streambuf",
   52     "stringbuf", "stringstream", "cerr", "cin", "clog", "cout", "fpos", "streamoff",
   53     "streampos", "streamsize"
   54   }
   55 
   56   chrono_items=Set {
   57     "duration",  "duration_values","high_resolution_clock","steady_clock","system_clock","time_point"
   58   }
   59 
   60   codecvt_items=Set {
   61     "codecvt_utf16","codecvt_utf8","codecvt_utf8_utf16"
   62   }
   63 
   64   random_items=Set {
   65     "bernoulli_distribution", "binomial_distribution", "cauchy_distribution", "chi_squared_distribution",
   66     "discrete_distribution", "exponential_distribution", "extreme_value_distribution",
   67     "fisher_f_distribution", "gamma_distribution", "geometric_distribution", "lognormal_distribution",
   68     "negative_binomial_distribution", "normal_distribution", "piecewise_constant_distribution",
   69     "piecewise_linear_distribution", "poisson_distribution", "student_t_distribution", "uniform_int_distribution",
   70     "uniform_real_distribution", "weibull_distribution"
   71   }
   72 
   73   ratio_items=Set {
   74     "ratio_add", "ratio_divide", "ratio_equal", "ratio_greater", "ratio_greater_equal", "ratio_less",
   75     "ratio_less_equal", "ratio_multiply", "ratio_not_equal", "ratio_subtract"
   76   }
   77 
   78   regex_items=Set {
   79     "basic_regex", "match_results", "regex_error", "regex_iterator", "regex_token_iterator", "regex_traits",
   80     "sub_match", "cmatch", "csub_match", "regex", "smatch", "ssub_match", "wcmatch", "wcsub_match",
   81     "wregex", "wsmatch", "wssub_match", "regex_replace", "regex_match", "regex_search"
   82   }
   83 
   84   system_error_items=Set {
   85       "error_category", "error_code", "error_condition", "is_error_code_enum", "is_error_condition_enum",
   86     "system_error", "errc", "generic_category", "make_error_code", "make_error_condition", "system_category"
   87   }
   88 
   89   tuple_items=Set {
   90     "tuple", "tuple_element", "tuple_size", "uses_allocator", "forward_as_tuple", "get", "make_tuple", "swap", "tie", "tuple_cat", "ignore"
   91   }
   92 
   93   type_traits_items=Set {
   94     "false_type", "integral_constant", "true_type", "alignment_of", "extent", "has_virtual_destructor", "is_abstract", "is_arithmetic", "is_array",
   95   "is_assignable", "is_base_of", "is_class", "is_compound", "is_const", "is_constructible", "is_convertible", "is_copy_assignable",
   96   "is_copy_constructible", "is_default_constructible", "is_destructible", "is_empty", "is_enum", "is_floating_point", "is_function",
   97   "is_fundamental", "is_integral", "is_literal_type", "is_lvalue_reference", "is_member_function_pointer", "is_member_object_pointer",
   98   "is_member_pointer", "is_move_assignable", "is_move_constructible", "is_nothrow_assignable", "is_nothrow_constructible", "is_nothrow_copy_assignable",
   99   "is_nothrow_copy_constructible", "is_nothrow_default_constructible", "is_nothrow_destructible", "is_nothrow_move_assignable", "is_nothrow_move_constructible",
  100   "is_object", "is_pod", "is_pointer", "is_polymorphic", "is_reference", "is_rvalue_reference", "is_same", "is_scalar", "is_signed", "is_standard_layout",
  101   "is_trivial", "is_trivially_assignable", "is_trivially_constructible", "is_trivially_copyable", "is_trivially_copy_assignable", "is_trivially_copy_constructible",
  102   "is_trivially_default_constructible", "is_trivially_destructible", "is_trivially_move_assignable", "is_trivially_move_constructible", "is_union", "is_unsigned",
  103   "is_void", "is_volatile", "rank", "add_const", "add_cv", "add_lvalue_reference", "add_pointer", "add_rvalue_reference", "add_volatile", "aligned_storage",
  104   "aligned_union", "common_type", "conditional", "decay", "enable_if", "make_signed", "make_unsigned", "remove_all_extents", "remove_const", "remove_cv",
  105   "remove_extent", "remove_pointer", "remove_reference", "remove_volatile", "result_of", "underlying_type"
  106 
  107   }
  108 
  109   function getURL(token, cat)
  110     url='http://www.cplusplus.com/reference/'..cat.. '/' .. token .. '/'
  111 
  112     if (HL_OUTPUT== HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then
  113       return '<a class="hl" target="new" href="' .. url .. '">'.. token .. '</a>'
  114     elseif (HL_OUTPUT == HL_FORMAT_LATEX) then
  115       return '\\href{'..url..'}{'..token..'}'
  116     elseif (HL_OUTPUT == HL_FORMAT_RTF) then
  117       return '{{\\field{\\*\\fldinst HYPERLINK "'..url..'" }{\\fldrslt\\ul\\ulc0 '..token..'}}}'
  118     elseif (HL_OUTPUT == HL_FORMAT_ODT) then
  119       return '<text:a xlink:type="simple" xlink:href="'..url..'">'..token..'</text:a>'
  120     end
  121   end
  122 
  123   function Decorate(token, state)
  124 
  125     if (state ~= HL_STANDARD and state ~= HL_KEYWORD and state ~=HL_PREPROC) then
  126       return
  127     end
  128 
  129     if string_items[token] then
  130       return  getURL(token, 'string')
  131     elseif stl_items[token] then
  132       return  getURL(token, 'stl')
  133     elseif algorithm_items[token] then
  134       return  getURL(token, 'algorithm')
  135     elseif clib_items[token] then
  136       return  getURL(token, 'clibrary')
  137     elseif iostream_items[token] then
  138       return  getURL(token, 'iostream')
  139     elseif chrono_items[token] then
  140       return  getURL(token, 'chrono')
  141     elseif codecvt_items[token] then
  142       return  getURL(token, 'codecvt')
  143     elseif random_items[token] then
  144       return  getURL(token, 'random')
  145     elseif ratio_items[token] then
  146       return  getURL(token, 'ratio')
  147     elseif regex_items[token] then
  148       return  getURL(token, 'regex')
  149     elseif system_error_items[token] then
  150       return  getURL(token, 'system_error')
  151     elseif tuple_items[token] then
  152       return  getURL(token, 'tuple')
  153     elseif type_traits_items[token] then
  154       return  getURL(token, 'type_traits')
  155     end
  156 
  157   end
  158 end
  159 
  160 
  161 function themeUpdate(desc)
  162   if (HL_OUTPUT == HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then
  163     Injections[#Injections+1]="a.hl, a.hl:visited {color:inherit;font-weight:inherit;}"
  164   elseif (HL_OUTPUT==HL_FORMAT_LATEX) then
  165     Injections[#Injections+1]="\\usepackage[colorlinks=false, pdfborderstyle={/S/U/W 1}]{hyperref}"
  166   end
  167 end
  168 
  169 --The Plugins array assigns code chunks to themes or language definitions.
  170 --The chunks are interpreted after the theme or lang file were parsed,
  171 --so you can refer to elements of these files
  172 
  173 Plugins={
  174 
  175   { Type="lang", Chunk=syntaxUpdate },
  176   { Type="theme", Chunk=themeUpdate },
  177 
  178 }