gitlab-pygments.rb 0.3.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +71 -0
  4. data/Gemfile +1 -1
  5. data/LICENSE +17 -0
  6. data/README.md +28 -1
  7. data/Rakefile +2 -5
  8. data/lexers +0 -0
  9. data/lib/pygments/mentos.py +19 -12
  10. data/lib/pygments/popen.rb +21 -4
  11. data/lib/pygments/version.rb +1 -1
  12. data/pygments.rb.gemspec +2 -0
  13. data/test/test_pygments.rb +13 -2
  14. data/vendor/custom_lexers/github.py +206 -3
  15. data/vendor/pygments-main/AUTHORS +41 -3
  16. data/vendor/pygments-main/CHANGES +132 -5
  17. data/vendor/pygments-main/LICENSE +1 -1
  18. data/vendor/pygments-main/Makefile +1 -1
  19. data/vendor/pygments-main/REVISION +1 -1
  20. data/vendor/pygments-main/docs/generate.py +1 -1
  21. data/vendor/pygments-main/docs/src/api.txt +1 -1
  22. data/vendor/pygments-main/docs/src/index.txt +1 -1
  23. data/vendor/pygments-main/docs/src/integrate.txt +5 -0
  24. data/vendor/pygments-main/docs/src/java.txt +70 -0
  25. data/vendor/pygments-main/docs/src/lexerdevelopment.txt +52 -0
  26. data/vendor/pygments-main/external/autopygmentize +64 -0
  27. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
  28. data/vendor/pygments-main/external/markdown-processor.py +2 -2
  29. data/vendor/pygments-main/external/moin-parser.py +1 -1
  30. data/vendor/pygments-main/external/rst-directive-old.py +1 -1
  31. data/vendor/pygments-main/external/rst-directive.py +1 -1
  32. data/vendor/pygments-main/pygmentize +1 -1
  33. data/vendor/pygments-main/pygments/__init__.py +2 -2
  34. data/vendor/pygments-main/pygments/cmdline.py +14 -6
  35. data/vendor/pygments-main/pygments/console.py +1 -1
  36. data/vendor/pygments-main/pygments/filter.py +1 -1
  37. data/vendor/pygments-main/pygments/filters/__init__.py +3 -4
  38. data/vendor/pygments-main/pygments/formatter.py +4 -1
  39. data/vendor/pygments-main/pygments/formatters/__init__.py +1 -1
  40. data/vendor/pygments-main/pygments/formatters/_mapping.py +3 -3
  41. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  42. data/vendor/pygments-main/pygments/formatters/html.py +73 -2
  43. data/vendor/pygments-main/pygments/formatters/img.py +2 -2
  44. data/vendor/pygments-main/pygments/formatters/latex.py +9 -9
  45. data/vendor/pygments-main/pygments/formatters/other.py +1 -3
  46. data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
  47. data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
  48. data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
  49. data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
  50. data/vendor/pygments-main/pygments/lexer.py +78 -10
  51. data/vendor/pygments-main/pygments/lexers/__init__.py +13 -2
  52. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  53. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +1 -1
  54. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
  55. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +1 -1
  56. data/vendor/pygments-main/pygments/lexers/_mapping.py +92 -36
  57. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
  58. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +2 -2
  59. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +4 -3
  60. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
  61. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +11 -0
  62. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
  63. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
  64. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -3
  65. data/vendor/pygments-main/pygments/lexers/agile.py +525 -38
  66. data/vendor/pygments-main/pygments/lexers/asm.py +45 -7
  67. data/vendor/pygments-main/pygments/lexers/compiled.py +1257 -425
  68. data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
  69. data/vendor/pygments-main/pygments/lexers/dotnet.py +97 -62
  70. data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
  71. data/vendor/pygments-main/pygments/lexers/functional.py +931 -32
  72. data/vendor/pygments-main/pygments/lexers/github.py +206 -3
  73. data/vendor/pygments-main/pygments/lexers/hdl.py +3 -3
  74. data/vendor/pygments-main/pygments/lexers/jvm.py +309 -44
  75. data/vendor/pygments-main/pygments/lexers/math.py +876 -30
  76. data/vendor/pygments-main/pygments/lexers/other.py +956 -517
  77. data/vendor/pygments-main/pygments/lexers/parsers.py +85 -2
  78. data/vendor/pygments-main/pygments/lexers/shell.py +81 -18
  79. data/vendor/pygments-main/pygments/lexers/special.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/sql.py +2 -2
  81. data/vendor/pygments-main/pygments/lexers/templates.py +119 -8
  82. data/vendor/pygments-main/pygments/lexers/text.py +155 -15
  83. data/vendor/pygments-main/pygments/lexers/web.py +1578 -397
  84. data/vendor/pygments-main/pygments/modeline.py +40 -0
  85. data/vendor/pygments-main/pygments/plugin.py +1 -1
  86. data/vendor/pygments-main/pygments/scanner.py +1 -1
  87. data/vendor/pygments-main/pygments/style.py +1 -1
  88. data/vendor/pygments-main/pygments/styles/__init__.py +1 -1
  89. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  90. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  91. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  92. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  93. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  94. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  95. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  96. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  97. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  98. data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
  99. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  100. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  101. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  102. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  103. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  104. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  105. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  106. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  107. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  108. data/vendor/pygments-main/pygments/token.py +1 -1
  109. data/vendor/pygments-main/pygments/unistring.py +36 -26
  110. data/vendor/pygments-main/pygments/util.py +46 -1
  111. data/vendor/pygments-main/scripts/check_sources.py +2 -2
  112. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +2 -0
  113. data/vendor/pygments-main/scripts/find_codetags.py +1 -1
  114. data/vendor/pygments-main/scripts/find_error.py +5 -6
  115. data/vendor/pygments-main/setup.cfg +1 -0
  116. data/vendor/pygments-main/setup.py +6 -4
  117. data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
  118. data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
  119. data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
  120. data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
  121. data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
  122. data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
  123. data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
  124. data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
  125. data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
  126. data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
  127. data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
  128. data/vendor/pygments-main/tests/examplefiles/classes.dylan +89 -4
  129. data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
  130. data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
  131. data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
  132. data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
  133. data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
  134. data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
  135. data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
  136. data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
  137. data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
  138. data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
  139. data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
  140. data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
  141. data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
  142. data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
  143. data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
  144. data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
  145. data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
  146. data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
  147. data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
  148. data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
  149. data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
  150. data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
  151. data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
  152. data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
  153. data/vendor/pygments-main/tests/examplefiles/http_request_example +2 -1
  154. data/vendor/pygments-main/tests/examplefiles/http_response_example +4 -2
  155. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
  156. data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
  157. data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
  158. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
  159. data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
  160. data/vendor/pygments-main/tests/examplefiles/matlab_sample +5 -2
  161. data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
  162. data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
  163. data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
  164. data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
  165. data/vendor/pygments-main/tests/examplefiles/objc_example.m +7 -0
  166. data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
  167. data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
  168. data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
  169. data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
  170. data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
  171. data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
  172. data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
  173. data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
  174. data/vendor/pygments-main/tests/examplefiles/test.R +149 -115
  175. data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
  176. data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
  177. data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
  178. data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
  179. data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
  180. data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
  181. data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
  182. data/vendor/pygments-main/tests/examplefiles/type.lisp +16 -0
  183. data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
  184. data/vendor/pygments-main/tests/old_run.py +1 -1
  185. data/vendor/pygments-main/tests/run.py +3 -2
  186. data/vendor/pygments-main/tests/support/tags +36 -0
  187. data/vendor/pygments-main/tests/test_basic_api.py +4 -3
  188. data/vendor/pygments-main/tests/test_clexer.py +1 -1
  189. data/vendor/pygments-main/tests/test_cmdline.py +1 -1
  190. data/vendor/pygments-main/tests/test_examplefiles.py +3 -1
  191. data/vendor/pygments-main/tests/test_html_formatter.py +17 -1
  192. data/vendor/pygments-main/tests/test_latex_formatter.py +1 -1
  193. data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
  194. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  195. data/vendor/pygments-main/tests/test_regexlexer.py +1 -1
  196. data/vendor/pygments-main/tests/test_token.py +1 -1
  197. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  198. data/vendor/pygments-main/tests/test_util.py +22 -3
  199. metadata +84 -16
@@ -0,0 +1,225 @@
1
+ //
2
+ // std::vector
3
+ //
4
+
5
+ %include <std_container.i>
6
+
7
+ // Vector
8
+
9
+ %define %std_vector_methods(vector...)
10
+ %std_sequence_methods(vector)
11
+
12
+ void reserve(size_type n);
13
+ size_type capacity() const;
14
+ %enddef
15
+
16
+
17
+ %define %std_vector_methods_val(vector...)
18
+ %std_sequence_methods_val(vector)
19
+
20
+ void reserve(size_type n);
21
+ size_type capacity() const;
22
+ %enddef
23
+
24
+
25
+ // ------------------------------------------------------------------------
26
+ // std::vector
27
+ //
28
+ // The aim of all that follows would be to integrate std::vector with
29
+ // as much as possible, namely, to allow the user to pass and
30
+ // be returned tuples or lists.
31
+ // const declarations are used to guess the intent of the function being
32
+ // exported; therefore, the following rationale is applied:
33
+ //
34
+ // -- f(std::vector<T>), f(const std::vector<T>&):
35
+ // the parameter being read-only, either a sequence or a
36
+ // previously wrapped std::vector<T> can be passed.
37
+ // -- f(std::vector<T>&), f(std::vector<T>*):
38
+ // the parameter may be modified; therefore, only a wrapped std::vector
39
+ // can be passed.
40
+ // -- std::vector<T> f(), const std::vector<T>& f():
41
+ // the vector is returned by copy; therefore, a sequence of T:s
42
+ // is returned which is most easily used in other functions
43
+ // -- std::vector<T>& f(), std::vector<T>* f():
44
+ // the vector is returned by reference; therefore, a wrapped std::vector
45
+ // is returned
46
+ // -- const std::vector<T>* f(), f(const std::vector<T>*):
47
+ // for consistency, they expect and return a plain vector pointer.
48
+ // ------------------------------------------------------------------------
49
+
50
+ %{
51
+ #include <vector>
52
+ %}
53
+
54
+ // exported classes
55
+
56
+
57
+ namespace std {
58
+
59
+ template<class _Tp, class _Alloc = allocator< _Tp > >
60
+ class vector {
61
+ public:
62
+ typedef size_t size_type;
63
+ typedef ptrdiff_t difference_type;
64
+ typedef _Tp value_type;
65
+ typedef value_type* pointer;
66
+ typedef const value_type* const_pointer;
67
+ typedef _Tp& reference;
68
+ typedef const _Tp& const_reference;
69
+ typedef _Alloc allocator_type;
70
+
71
+ %traits_swigtype(_Tp);
72
+ %traits_enum(_Tp);
73
+
74
+ %fragment(SWIG_Traits_frag(std::vector<_Tp, _Alloc >), "header",
75
+ fragment=SWIG_Traits_frag(_Tp),
76
+ fragment="StdVectorTraits") {
77
+ namespace swig {
78
+ template <> struct traits<std::vector<_Tp, _Alloc > > {
79
+ typedef pointer_category category;
80
+ static const char* type_name() {
81
+ return "std::vector<" #_Tp "," #_Alloc " >";
82
+ }
83
+ };
84
+ }
85
+ }
86
+
87
+ %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp, _Alloc >);
88
+
89
+ #ifdef %swig_vector_methods
90
+ // Add swig/language extra methods
91
+ %swig_vector_methods(std::vector<_Tp, _Alloc >);
92
+ #endif
93
+
94
+ %std_vector_methods(vector);
95
+ };
96
+
97
+ // ***
98
+ // This specialization should disappear or get simplified when
99
+ // a 'const SWIGTYPE*&' can be defined
100
+ // ***
101
+ template<class _Tp, class _Alloc >
102
+ class vector<_Tp*, _Alloc > {
103
+ public:
104
+ typedef size_t size_type;
105
+ typedef ptrdiff_t difference_type;
106
+ typedef _Tp* value_type;
107
+ typedef value_type* pointer;
108
+ typedef const value_type* const_pointer;
109
+ typedef value_type reference;
110
+ typedef value_type const_reference;
111
+ typedef _Alloc allocator_type;
112
+
113
+ %traits_swigtype(_Tp);
114
+
115
+ %fragment(SWIG_Traits_frag(std::vector<_Tp*, _Alloc >), "header",
116
+ fragment=SWIG_Traits_frag(_Tp),
117
+ fragment="StdVectorTraits") {
118
+ namespace swig {
119
+ template <> struct traits<std::vector<_Tp*, _Alloc > > {
120
+ typedef value_category category;
121
+ static const char* type_name() {
122
+ return "std::vector<" #_Tp " *," #_Alloc " >";
123
+ }
124
+ };
125
+ }
126
+ }
127
+
128
+ %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp*, _Alloc >);
129
+
130
+ #ifdef %swig_vector_methods_val
131
+ // Add swig/language extra methods
132
+ %swig_vector_methods_val(std::vector<_Tp*, _Alloc >);
133
+ #endif
134
+
135
+ %std_vector_methods_val(vector);
136
+ };
137
+
138
+ // ***
139
+ // const pointer specialization
140
+ // ***
141
+ template<class _Tp, class _Alloc >
142
+ class vector<_Tp const *, _Alloc > {
143
+ public:
144
+ typedef size_t size_type;
145
+ typedef ptrdiff_t difference_type;
146
+ typedef _Tp const * value_type;
147
+ typedef value_type* pointer;
148
+ typedef const value_type* const_pointer;
149
+ typedef value_type reference;
150
+ typedef value_type const_reference;
151
+ typedef _Alloc allocator_type;
152
+
153
+ %traits_swigtype(_Tp);
154
+
155
+ %fragment(SWIG_Traits_frag(std::vector<_Tp const*, _Alloc >), "header",
156
+ fragment=SWIG_Traits_frag(_Tp),
157
+ fragment="StdVectorTraits") {
158
+ namespace swig {
159
+ template <> struct traits<std::vector<_Tp const*, _Alloc > > {
160
+ typedef value_category category;
161
+ static const char* type_name() {
162
+ return "std::vector<" #_Tp " const*," #_Alloc " >";
163
+ }
164
+ };
165
+ }
166
+ }
167
+
168
+ %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp const*, _Alloc >);
169
+
170
+ #ifdef %swig_vector_methods_val
171
+ // Add swig/language extra methods
172
+ %swig_vector_methods_val(std::vector<_Tp const*, _Alloc >);
173
+ #endif
174
+
175
+ %std_vector_methods_val(vector);
176
+ };
177
+
178
+ // ***
179
+ // bool specialization
180
+ // ***
181
+
182
+ template<class _Alloc >
183
+ class vector<bool,_Alloc > {
184
+ public:
185
+ typedef size_t size_type;
186
+ typedef ptrdiff_t difference_type;
187
+ typedef bool value_type;
188
+ typedef value_type* pointer;
189
+ typedef const value_type* const_pointer;
190
+ typedef value_type reference;
191
+ typedef value_type const_reference;
192
+ typedef _Alloc allocator_type;
193
+
194
+ %traits_swigtype(bool);
195
+
196
+ %fragment(SWIG_Traits_frag(std::vector<bool, _Alloc >), "header",
197
+ fragment=SWIG_Traits_frag(bool),
198
+ fragment="StdVectorTraits") {
199
+ namespace swig {
200
+ template <> struct traits<std::vector<bool, _Alloc > > {
201
+ typedef value_category category;
202
+ static const char* type_name() {
203
+ return "std::vector<bool, _Alloc >";
204
+ }
205
+ };
206
+ }
207
+ }
208
+
209
+ %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool, _Alloc >);
210
+
211
+
212
+ #ifdef %swig_vector_methods_val
213
+ // Add swig/language extra methods
214
+ %swig_vector_methods_val(std::vector<bool, _Alloc >);
215
+ #endif
216
+
217
+ %std_vector_methods_val(vector);
218
+
219
+ #if defined(SWIG_STD_MODERN_STL) && !defined(SWIG_STD_NOMODERN_STL)
220
+ void flip();
221
+ #endif
222
+
223
+ };
224
+
225
+ }
@@ -1,119 +1,153 @@
1
- ###################################
2
- ####### emplikH1.test() ##########
3
- ###################################
4
-
5
- emplikH1.test <- function(x, d, theta, fun,
6
- tola = .Machine$double.eps^.25)
7
- {
8
- n <- length(x)
9
- if( n <= 2 ) stop("Need more observations")
10
- if( length(d) != n ) stop("length of x and d must agree")
11
- if(any((d!=0)&(d!=1))) stop("d must be 0/1's for censor/not-censor")
12
- if(!is.numeric(x)) stop("x must be numeric values --- observed times")
13
-
14
- #temp<-summary(survfit(Surv(x,d),se.fit=F,type="fleming",conf.type="none"))
15
- #
16
- newdata <- Wdataclean2(x,d)
17
- temp <- DnR(newdata$value, newdata$dd, newdata$weight)
18
-
19
- time <- temp$time # only uncensored time? Yes.
20
- risk <- temp$n.risk
21
- jump <- (temp$n.event)/risk
22
-
23
- funtime <- fun(time)
24
- funh <- (n/risk) * funtime # that is Zi
25
- funtimeTjump <- funtime * jump
26
-
27
- if(jump[length(jump)] >= 1) funh[length(jump)] <- 0 #for inthaz and weights
28
-
29
- inthaz <- function(x, ftj, fh, thet){ sum(ftj/(1 + x * fh)) - thet }
30
-
31
- diff <- inthaz(0, funtimeTjump, funh, theta)
32
-
33
- if( diff == 0 ) { lam <- 0 } else {
34
- step <- 0.2/sqrt(n)
35
- if(abs(diff) > 6*log(n)*step )
36
- stop("given theta value is too far away from theta0")
37
-
38
- mini<-0
39
- maxi<-0
40
- if(diff > 0) {
41
- maxi <- step
42
- while(inthaz(maxi, funtimeTjump, funh, theta) > 0 && maxi < 50*log(n)*step)
43
- maxi <- maxi+step
44
- }
45
- else {
46
- mini <- -step
47
- while(inthaz(mini, funtimeTjump, funh, theta) < 0 && mini > - 50*log(n)*step)
48
- mini <- mini - step
49
- }
50
-
51
- if(inthaz(mini, funtimeTjump, funh, theta)*inthaz(maxi, funtimeTjump, funh, theta) > 0 )
52
- stop("given theta is too far away from theta0")
53
-
54
- temp2 <- uniroot(inthaz,c(mini,maxi), tol = tola,
55
- ftj=funtimeTjump, fh=funh, thet=theta)
56
- lam <- temp2$root
1
+ #!/usr/bin/env Rscript
2
+ ### Example R script for syntax highlighting
3
+
4
+ # This is also a comment
5
+
6
+ ## Valid names
7
+ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV0123456789._a <- NULL
8
+ .foo_ <- NULL
9
+ ._foo <- NULL
10
+
11
+ ## Invalid names
12
+ 0abc <- NULL
13
+ .0abc <- NULL
14
+ abc+cde <- NULL
15
+
16
+ ## Reserved Words
17
+ NA
18
+ NA_integer_
19
+ NA_real_
20
+ NA_character_
21
+ NA_complex_
22
+ NULL
23
+ NaN
24
+ Inf
25
+ ## Not reserved
26
+ NULLa <- NULL
27
+ NULL1 <- NULL
28
+ NULL. <- NULL
29
+ NA_foo_ <- NULL
30
+
31
+ ## Numbers
32
+ 12345678901
33
+ 123456.78901
34
+ 123e3
35
+ 123E3
36
+ 1.23e-3
37
+ 1.23e3
38
+ 1.23e-3
39
+ ## integer constants
40
+ 123L
41
+ 1.23L
42
+ ## imaginary numbers
43
+ 123i
44
+ -123i
45
+ 123e4i
46
+ 123e-4i
47
+ ## Hex numbers
48
+ 0xabcdefABCDEF01234
49
+ 0xabcp123
50
+ 0xabcP123
51
+ ## Not hex
52
+ 0xg
53
+
54
+ ## Special operators %xyz%
55
+ ## %xyz%
56
+ 1 %% 2
57
+ diag(2) %*% diag(2)
58
+ 1 %/% 2
59
+ 1 %in% 1:10
60
+ diag(2) %o% diag(2)
61
+ diag(2) %x% diag(2)
62
+ `%foo bar%` <- function(x, y) x + y
63
+ 1 %foo bar% 2
64
+
65
+ ## Control Structures (3.2) and Function
66
+ ## if, else
67
+ if (TRUE) print("foo") else print("bar")
68
+ ## For, in
69
+ for(i in 1:5) {
70
+ print(i)
57
71
  }
58
-
59
- onepluslamh<- 1 + lam * funh ### this is 1 + lam Zi in Ref.
60
-
61
- weights <- jump/onepluslamh #need to change last jump to 1? NO. see above
62
-
63
- loglik <- 2*(sum(log(onepluslamh)) - sum((onepluslamh-1)/onepluslamh) )
64
- #?is that right? YES see (3.2) in Ref. above. This ALR, or Poisson LR.
65
-
66
- #last <- length(jump) ## to compute loglik2, we need to drop last jump
67
- #if (jump[last] == 1) {
68
- # risk1 <- risk[-last]
69
- # jump1 <- jump[-last]
70
- # weights1 <- weights[-last]
71
- # } else {
72
- # risk1 <- risk
73
- # jump1 <- jump
74
- # weights1 <- weights
75
- # }
76
- #loglik2 <- 2*( sum(log(onepluslamh)) +
77
- # sum( (risk1 -1)*log((1-jump1)/(1- weights1) ) ) )
78
- ##? this likelihood seems have negative values sometimes???
79
-
80
- list( logemlik=loglik, ### logemlikv2=loglik2,
81
- lambda=lam, times=time, wts=weights,
82
- nits=temp2$nf, message=temp2$message )
72
+ ## While, break
73
+ i <- 1
74
+ while (TRUE) {
75
+ i <- i + 1
76
+ if (i > 3) break
83
77
  }
84
-
85
- library("graphics")
86
-
87
- par(mfrow = c(1, 2))
88
- # plot histogram
89
- x <- rnorm(100)
90
- if (max(x) > 100)
91
- stop("Quite unexpected.")
92
- else
93
- hist(x, plot=TRUE, col="ivory")
94
-
95
- # from doc: lowess
96
- plot(cars, main = "lowess(cars)")
97
- lines(lowess(cars), col = 2)
98
- lines(lowess(cars, f=.2), col = 3)
99
- legend(5, 120, c(paste("f = ", c("2/3", ".2"))), lty = 1, col = 2:3)
100
-
101
- # from doc: is.na
102
- is.na(c(1, NA))
103
-
104
- # from doc: Extract
105
- y <- list(1,2,a=4,5)
106
- y[c(3,4)] # a list containing elements 3 and 4 of y
107
- y$a # the element of y named a
108
-
109
- # from doc: for
110
- for(n in c(2,5,10,20,50)) {
111
- x <- stats::rnorm(n)
112
- cat(n,":", sum(x2),"\n")
78
+ ## Repeat
79
+ repeat {1+1}
80
+ ## Switch
81
+ x <- 3
82
+ switch(x, 2+2, mean(1:10), rnorm(5))
83
+ ## Function, dot-dot-dot, return
84
+ foo <- function(...) {
85
+ return(sum(...))
86
+ }
87
+ # Not keywords
88
+ functiona <- 2 + 2
89
+ function. <- 2 + 2
90
+ function1 <- 2 + 2
91
+
92
+
93
+ ## Grouping Tokens 10.3.7
94
+ ## Parentheses
95
+ 1 + (2 + 3)
96
+ ## brackets
97
+ foo <- function(a) {
98
+ a + 1
113
99
  }
114
100
 
115
- class(fo <- y ~ x1*x2) # "formula"
116
-
117
-
118
-
119
-
101
+ ## Indexing 10.3.8
102
+ ## []
103
+ bar <- 1:10
104
+ bar[3]
105
+ ## [[]]
106
+ foo <- list(a=1, b=2, c=3)
107
+ foo[["a"]]
108
+ ## $
109
+ foo$a
110
+ foo$"a"
111
+
112
+ ## Operators
113
+ 2 - 2
114
+ 2 + 2
115
+ 2 ~ 2
116
+ ! TRUE
117
+ ?"help"
118
+ 1:2
119
+ 2 * 2
120
+ 2 / 2
121
+ 2^2
122
+ 2 < 2
123
+ 2 > 2
124
+ 2 == 2
125
+ 2 >= 2
126
+ 2 <= 2
127
+ 2 != 2
128
+ TRUE & FALSE
129
+ TRUE && FALSE
130
+ TRUE | FALSE
131
+ TRUE || FALSE
132
+ foo <- 2 + 2
133
+ foo = 2 + 2
134
+ 2 + 2 -> foo
135
+ foo <<- 2 + 2
136
+ 2 + 2 ->> foo
137
+ base:::sum
138
+ base::sum
139
+
140
+ ## Strings
141
+ foo <- "hello, world!"
142
+ foo <- 'hello, world!'
143
+ foo <- "Hello, 'world!"
144
+ foo <- 'Hello, "world!'
145
+ foo <- 'Hello, \'world!\''
146
+ foo <- "Hello, \"world!\""
147
+ foo <- "Hello,
148
+ world!"
149
+ foo <- 'Hello,
150
+ world!'
151
+
152
+ ## Backtick strings
153
+ `foo123 +!"bar'baz` <- 2 + 2