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,133 @@
1
+ // Koka language test module
2
+
3
+ // This module implements the GarsiaWachs algorithm.
4
+ // It is an adaptation of the algorithm in ML as described by JeanChristophe Filli�tre:
5
+ // in ''A functional implementation of the GarsiaWachs algorithm. (functional pearl). ML workshop 2008, pages 91--96''.
6
+ // See: http://www.lri.fr/~filliatr/publis/gwWml08.pdf
7
+ //
8
+ // The algorithm is interesting since it uses mutable references shared between a list and tree but the
9
+ // side effects are not observable from outside. Koka automatically infers that the final algorithm is pure.
10
+ // Note: due to a current limitation in the divergence analysis, koka cannot yet infer that mutually recursive
11
+ // definitions in "insert" and "extract" are terminating and the final algorithm still has a divergence effect.
12
+ // However, koka does infer that no other effect (i.e. an exception due to a partial match) can occur.
13
+ module garcsiaWachs
14
+
15
+ import test = qualified std/flags
16
+
17
+ # pre processor test
18
+
19
+ public function main() {
20
+ wlist = Cons1(('a',3), [('b',2),('c',1),('d',4),('e',5)])
21
+ tree = wlist.garsiaWachs()
22
+ tree.show.println()
23
+ }
24
+
25
+ //----------------------------------------------------
26
+ // Trees
27
+ //----------------------------------------------------
28
+ public type tree<a> {
29
+ con Leaf(value :a)
30
+ con Node(left :tree<a>, right :tree<a>)
31
+ }
32
+
33
+ function show( t : tree<char> ) : string {
34
+ match(t) {
35
+ Leaf(c) -> core/show(c)
36
+ Node(l,r) -> "Node(" + show(l) + "," + show(r) + ")"
37
+ }
38
+ }
39
+
40
+
41
+ //----------------------------------------------------
42
+ // Non empty lists
43
+ //----------------------------------------------------
44
+ public type list1<a> {
45
+ Cons1( head : a, tail : list<a> )
46
+ }
47
+
48
+ function map( xs, f ) {
49
+ val Cons1(y,ys) = xs
50
+ return Cons1(f(y), core/map(ys,f))
51
+ }
52
+
53
+ function zip( xs :list1<a>, ys :list1<b> ) : list1<(a,b)> {
54
+ Cons1( (xs.head, ys.head), zip(xs.tail, ys.tail))
55
+ }
56
+
57
+
58
+ //----------------------------------------------------
59
+ // Phase 1
60
+ //----------------------------------------------------
61
+
62
+ function insert( after : list<(tree<a>,int)>, t : (tree<a>,int), before : list<(tree<a>,int)> ) : div tree<a>
63
+ {
64
+ match(before) {
65
+ Nil -> extract( [], Cons1(t,after) )
66
+ Cons(x,xs) -> {
67
+ if (x.snd < t.snd) then return insert( Cons(x,after), t, xs )
68
+ match(xs) {
69
+ Nil -> extract( [], Cons1(x,Cons(t,after)) )
70
+ Cons(y,ys) -> extract( ys, Cons1(y,Cons(x,Cons(t,after))) )
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ function extract( before : list<(tree<a>,int)>, after : list1<(tree<a>,int)> ) : div tree<a>
77
+ {
78
+ val Cons1((t1,w1) as x, xs ) = after
79
+ match(xs) {
80
+ Nil -> t1
81
+ Cons((t2,w2) as y, ys) -> match(ys) {
82
+ Nil -> insert( [], (Node(t1,t2), w1+w2), before )
83
+ Cons((_,w3),_zs) ->
84
+ if (w1 <= w3)
85
+ then insert(ys, (Node(t1,t2), w1+w2), before)
86
+ else extract(Cons(x,before), Cons1(y,ys))
87
+ }
88
+ }
89
+ }
90
+
91
+ function balance( xs : list1<(tree<a>,int)> ) : div tree<a> {
92
+ extract( [], xs )
93
+ }
94
+
95
+ //----------------------------------------------------
96
+ // Phase 2
97
+ //----------------------------------------------------
98
+
99
+ function mark( depth :int, t :tree<(a,ref<h,int>)> ) : <write<h>> () {
100
+ match(t) {
101
+ Leaf((_,d)) -> d := depth
102
+ Node(l,r) -> { mark(depth+1,l); mark(depth+1,r) }
103
+ }
104
+ }
105
+
106
+ function build( depth :int, xs :list1<(a,ref<h,int>)> ) : <read<h>,div> (tree<a>,list<(a,ref<h,int>)>)
107
+ {
108
+ if (!(xs.head.snd) == depth) return (Leaf(xs.head.fst), xs.tail)
109
+
110
+ l = build(depth+1, xs)
111
+ match(l.snd) {
112
+ Nil -> (l.fst, Nil)
113
+ Cons(y,ys) -> {
114
+ r = build(depth+1, Cons1(y,ys))
115
+ (Node(l.fst,r.fst), r.snd)
116
+ }
117
+ }
118
+ }
119
+
120
+ //----------------------------------------------------
121
+ // Main
122
+ //----------------------------------------------------
123
+
124
+ public function garsiaWachs( xs : list1<(a,int)> ) : div tree<a>
125
+ {
126
+ refs = xs.map(fst).map( fun(x) { (x, ref(0)) } )
127
+ wleafs = zip( refs.map(Leaf), xs.map(snd) )
128
+
129
+ tree = balance(wleafs)
130
+ mark(0,tree)
131
+ build(0,refs).fst
132
+ }
133
+
@@ -0,0 +1,22 @@
1
+ token pod_formatting_code {
2
+ $<code>=<[A..Z]>
3
+ '<' { $*POD_IN_FORMATTINGCODE := 1 }
4
+ $<content>=[ <!before '>'> <pod_string_character> ]+
5
+ '>' { $*POD_IN_FORMATTINGCODE := 0 }
6
+ }
7
+
8
+ token pod_string {
9
+ <pod_string_character>+
10
+ }
11
+
12
+ token something:sym«<» {
13
+ <!>
14
+ }
15
+
16
+ token name {
17
+ <!>
18
+ }
19
+
20
+ token comment:sym<#> {
21
+ '#' {} \N*
22
+ }
@@ -0,0 +1,40 @@
1
+ # To Recreate:
2
+ #
3
+ # echo -e 'class hello {\n public static void main(String[] args) {\n
4
+ # System.out.println("hi");\n }\n}\n' > hello.java
5
+ # javac -target 1.4 -source 1.4 hello.java
6
+ # dx --dex --output=hello.dex hello.class
7
+ # baksmali hello.dex
8
+ # cat out/hello.smali
9
+
10
+ .class Lhello;
11
+ .super Ljava/lang/Object;
12
+ .source "hello.java"
13
+
14
+
15
+ # direct methods
16
+ .method constructor <init>()V
17
+ .registers 1
18
+
19
+ .prologue
20
+ .line 1
21
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
22
+
23
+ return-void
24
+ .end method
25
+
26
+ .method public static main([Ljava/lang/String;)V
27
+ .registers 3
28
+ .parameter
29
+
30
+ .prologue
31
+ .line 3
32
+ sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
33
+
34
+ const-string v1, "hi"
35
+
36
+ invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
37
+
38
+ .line 4
39
+ return-void
40
+ .end method
@@ -0,0 +1,9 @@
1
+ #include <sourcemod>
2
+
3
+ // Single line comment
4
+ /* Multi line
5
+ comment */
6
+
7
+ public OnPluginStart() {
8
+ PrintToServer("Hello.");
9
+ }
@@ -3,7 +3,8 @@ Host: pygments.org
3
3
  Connection: keep-alivk
4
4
  Cache-Control: max-age=0
5
5
  Origin: http://pygments.org
6
- User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
6
+ User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2)
7
+ AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
7
8
  Content-Type: application/x-www-form-urlencoded
8
9
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
9
10
  Referer: http://pygments.org/
@@ -18,8 +18,10 @@ Expires: Tue, 31 Mar 1981 05:00:00 GMT
18
18
  Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
19
19
  X-MID: a55f21733bc52bb11d1fc58f9b51b4974fbb8f83
20
20
  X-RateLimit-Reset: 1323738416
21
- Set-Cookie: k=10.34.234.116.1323735104238974; path=/; expires=Tue, 20-Dec-11 00:11:44 GMT; domain=.twitter.com
22
- Set-Cookie: guest_id=v1%3A13237351042425496; domain=.twitter.com; path=/; expires=Thu, 12-Dec-2013 12:11:44 GMT
21
+ Set-Cookie: k=10.34.234.116.1323735104238974; path=/;
22
+ expires=Tue, 20-Dec-11 00:11:44 GMT; domain=.twitter.com
23
+ Set-Cookie: guest_id=v1%3A13237351042425496; domain=.twitter.com; path=/;
24
+ expires=Thu, 12-Dec-2013 12:11:44 GMT
23
25
  Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCPS6wjQ0AToHaWQiJTFiMTlhY2E1ZjczYThk%250ANDUwMWQxNjMwZGU2YTQ1ODBhIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--6b502f30a083e8a41a64f10930e142ea362b1561; domain=.twitter.com; path=/; HttpOnly
24
26
  Vary: Accept-Encoding
25
27
  Server: tfe
@@ -0,0 +1,71 @@
1
+ re = import!
2
+ sys = import!
3
+
4
+
5
+ # IPv6address = hexpart [ ":" IPv4address ]
6
+ # IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
7
+ # hexpart = [ hexseq ] [ "::" [ hexseq ] ]
8
+ # hexseq = hex4 *( ":" hex4)
9
+ # hex4 = 1*4HEXDIG
10
+ hexpart = r'({0}|)(?:::({0}|)|)'.format r'(?:[\da-f]{1,4})(?::[\da-f]{1,4})*'
11
+ addrv4 = r'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})'
12
+ addrv6 = re.compile $ r'(?i)(?:{})(?::{})?$'.format hexpart addrv4
13
+
14
+
15
+ # Parse a base-N number given a list of its digits.
16
+ #
17
+ # :param q: the number of digits in that numeral system
18
+ #
19
+ # :param digits: an iterable of integers in range [0..q]
20
+ #
21
+ # :return: a decimal integer
22
+ #
23
+ base_n = (q digits) -> foldl (x y) -> (x * q + y) 0 digits
24
+
25
+
26
+ # Parse a sequence of hexadecimal numbers
27
+ #
28
+ # :param q: a string of colon-separated base-16 integers
29
+ #
30
+ # :return: an iterable of Python ints
31
+ #
32
+ unhex = q -> q and map p -> (int p 16) (q.split ':')
33
+
34
+
35
+ # Parse an IPv6 address as specified in RFC 4291.
36
+ #
37
+ # :param address: a string, obviously.
38
+ #
39
+ # :return: an integer which, written in binary form, points to the same node.
40
+ #
41
+ inet_pton6 = address ->
42
+ raise $ ValueError 'not a valid IPv6 address' if not (match = addrv6.match address)
43
+ start, end, *ipv4 = match.groups!
44
+
45
+ is_ipv4 = not $ None in ipv4
46
+ shift = (7 - start.count ':' - 2 * is_ipv4) * 16
47
+
48
+ raise $ ValueError 'not a valid IPv6 address' if (end is None and shift) or shift < 0
49
+ hexaddr = (base_n 0x10000 (unhex start) << shift) + base_n 0x10000 (unhex $ end or '')
50
+ (hexaddr << 32) + base_n 0x100 (map int ipv4) if is_ipv4 else hexaddr
51
+
52
+
53
+ inet6_type = q -> switch
54
+ not q = 'unspecified'
55
+ q == 1 = 'loopback'
56
+ (q >> 32) == 0x000000000000ffff = 'IPv4-mapped'
57
+ (q >> 64) == 0xfe80000000000000 = 'link-local'
58
+ (q >> 120) != 0x00000000000000ff = 'general unicast'
59
+ (q >> 112) % (1 << 4) == 0x0000000000000000 = 'multicast w/ reserved scope value'
60
+ (q >> 112) % (1 << 4) == 0x000000000000000f = 'multicast w/ reserved scope value'
61
+ (q >> 112) % (1 << 4) == 0x0000000000000001 = 'interface-local multicast'
62
+ (q >> 112) % (1 << 4) == 0x0000000000000004 = 'admin-local multicast'
63
+ (q >> 112) % (1 << 4) == 0x0000000000000005 = 'site-local multicast'
64
+ (q >> 112) % (1 << 4) == 0x0000000000000008 = 'organization-local multicast'
65
+ (q >> 112) % (1 << 4) == 0x000000000000000e = 'global multicast'
66
+ (q >> 112) % (1 << 4) != 0x0000000000000002 = 'multicast w/ unknown scope value'
67
+ (q >> 24) % (1 << 112) == 0x00000000000001ff = 'solicited-node multicast'
68
+ True = 'link-local multicast'
69
+
70
+
71
+ print $ (x -> (inet6_type x, hex x)) $ inet_pton6 $ sys.stdin.read!.strip!
@@ -0,0 +1,301 @@
1
+ <?LassoScript
2
+
3
+ //
4
+ // JSON Encoding and Decoding
5
+ //
6
+ // Copyright 2007-2012 LassoSoft Inc.
7
+ //
8
+ // <http://json.org/>
9
+ // <http://json-rpc.org/>
10
+ // <http://www.ietf.org/rfc/rfc4627.txt?number=4627>
11
+ //
12
+
13
+ If: (Lasso_TagExists: 'Encode_JSON') == False;
14
+
15
+ Define_Tag: 'JSON', -Namespace='Encode_', -Required='value', -Optional='options';
16
+
17
+ Local: 'escapes' = Map('\\' = '\\', '"' = '"', '\r' = 'r', '\n' = 'n', '\t' = 't', '\f' = 'f', '\b' = 'b');
18
+ Local: 'output' = '';
19
+ Local: 'newoptions' = (Array: -Internal);
20
+ If: !(Local_Defined: 'options') || (#options->(IsA: 'array') == False);
21
+ Local: 'options' = (Array);
22
+ /If;
23
+ If: (#options >> -UseNative) || (Params >> -UseNative);
24
+ #newoptions->(Insert: -UseNative);
25
+ /If;
26
+ If: (#options >> -NoNative) || (Params >> -NoNative);
27
+ #newoptions->(Insert: -NoNative);
28
+ /If;
29
+ If: (#options !>> -UseNative) && ((#value->(IsA: 'set')) || (#value->(IsA: 'list')) || (#value->(IsA: 'queue')) || (#value->(IsA: 'priorityqueue')) || (#value->(IsA: 'stack')));
30
+ #output += (Encode_JSON: Array->(insertfrom: #value->iterator) &, -Options=#newoptions);
31
+ Else: (#options !>> -UseNative) && (#value->(IsA: 'pair'));
32
+ #output += (Encode_JSON: (Array: #value->First, #value->Second));
33
+ Else: (#options !>> -Internal) && (#value->(Isa: 'array') == False) && (#value->(IsA: 'map') == False);
34
+ #output += '[' + (Encode_JSON: #value, -Options=#newoptions) + ']';
35
+ Else: (#value->(IsA: 'literal'));
36
+ #output += #value;
37
+ Else: (#value->(IsA: 'string'));
38
+ #output += '"';
39
+ Loop: (#value->Length);
40
+ Local('character' = #value->(Get: Loop_Count));
41
+ #output->(Append:
42
+ (Match_RegExp('[\\x{0020}-\\x{21}\\x{23}-\\x{5b}\\x{5d}-\\x{10fff}]') == #character) ? #character |
43
+ '\\' + (#escapes->(Contains: #character) ? #escapes->(Find: #character) | 'u' + String(Encode_Hex(#character))->PadLeading(4, '0')&)
44
+ );
45
+ /Loop;
46
+ #output += '"';
47
+ Else: (#value->(IsA: 'integer')) || (#value->(IsA: 'decimal')) || (#value->(IsA: 'boolean'));
48
+ #output += (String: #value);
49
+ Else: (#value->(IsA: 'null'));
50
+ #output += 'null';
51
+ Else: (#value->(IsA: 'date'));
52
+ If: #value->gmt;
53
+ #output += '"' + #value->(format: '%QT%TZ') + '"';
54
+ Else;
55
+ #output += '"' + #value->(format: '%QT%T') + '"';
56
+ /If;
57
+ Else: (#value->(IsA: 'array'));
58
+ #output += '[';
59
+ Iterate: #value, (Local: 'temp');
60
+ #output += (Encode_JSON: #temp, -Options=#newoptions);
61
+ If: #value->Size != Loop_Count;
62
+ #output += ', ';
63
+ /If;
64
+ /Iterate;
65
+ #output += ']';
66
+ Else: (#value->(IsA: 'object'));
67
+ #output += '{';
68
+ Iterate: #value, (Local: 'temp');
69
+ #output += #temp->First + ': ' + (Encode_JSON: #temp->Second, -Options=#newoptions);
70
+ If: (#value->Size != Loop_Count);
71
+ #output += ', ';
72
+ /If;
73
+ /Iterate;
74
+ #output += '}';
75
+ Else: (#value->(IsA: 'map'));
76
+ #output += '{';
77
+ Iterate: #value, (Local: 'temp');
78
+ #output += (Encode_JSON: #temp->First, -Options=#newoptions) + ': ' + (Encode_JSON: #temp->Second, -Options=#newoptions);
79
+ If: (#value->Size != Loop_Count);
80
+ #output += ', ';
81
+ /If;
82
+ /Iterate;
83
+ #output += '}';
84
+ Else: (#value->(IsA: 'client_ip')) || (#value->(IsA: 'client_address'));
85
+ #output += (Encode_JSON: (String: #value), -Options=#newoptions);
86
+ Else: (#options !>> -UseNative) && (#value->(IsA: 'set')) || (#value->(IsA: 'list')) || (#value->(IsA: 'queue')) || (#value->(IsA: 'priorityqueue')) || (#value->(IsA: 'stack'));
87
+ #output += (Encode_JSON: Array->(insertfrom: #value->iterator) &, -Options=#newoptions);
88
+ Else: (#options !>> -NoNative);
89
+ #output += (Encode_JSON: (Map: '__jsonclass__'=(Array:'deserialize',(Array:'<LassoNativeType>' + #value->Serialize + '</LassoNativeType>'))));
90
+ /If;
91
+ Return: @#output;
92
+
93
+ /Define_Tag;
94
+
95
+ /If;
96
+
97
+ If: (Lasso_TagExists: 'Decode_JSON') == False;
98
+
99
+ Define_Tag: 'JSON', -Namespace='Decode_', -Required='value';
100
+
101
+ (#value == '') ? Return: Null;
102
+
103
+ Define_Tag: 'consume_string', -Required='ibytes';
104
+ Local: 'unescapes' = (map: 34 = '"', 92 = '\\', 98 = '\b', 102 = '\f', 110 = '\n', 114 = '\r', 116 = '\t');
105
+ Local: 'temp' = 0, 'obytes' = Bytes;
106
+ While: ((#temp := #ibytes->export8bits) != 34); // '"'
107
+ If: (#temp === 92); // '\'
108
+ #temp = #ibytes->export8bits;
109
+ If: (#temp === 117); // 'u'
110
+ #obytes->(ImportString: (Decode_Hex: (String: #ibytes->(GetRange: #ibytes->Position + 1, 4)))->(ExportString: 'UTF-16'), 'UTF-8');
111
+ #ibytes->(SetPosition: #ibytes->Position + 4);
112
+ Else;
113
+ If: (#unescapes->(Contains: #temp));
114
+ #obytes->(ImportString: #unescapes->(Find: #temp), 'UTF-8');
115
+ Else;
116
+ #obytes->(Import8Bits: #temp);
117
+ /If;
118
+ /If;
119
+ Else;
120
+ #obytes->(Import8Bits: #temp);
121
+ /If;
122
+ /While;
123
+ Local('output' = #obytes->(ExportString: 'UTF-8'));
124
+ If: #output->(BeginsWith: '<LassoNativeType>') && #output->(EndsWith: '</LassoNativeType>');
125
+ Local: 'temp' = #output - '<LassoNativeType>' - '</LassoNativeType>';
126
+ Local: 'output' = null;
127
+ Protect;
128
+ #output->(Deserialize: #temp);
129
+ /Protect;
130
+ Else: (Valid_Date: #output, -Format='%QT%TZ');
131
+ Local: 'output' = (Date: #output, -Format='%QT%TZ');
132
+ Else: (Valid_Date: #output, -Format='%QT%T');
133
+ Local: 'output' = (Date: #output, -Format='%QT%T');
134
+ /If;
135
+ Return: @#output;
136
+ /Define_Tag;
137
+
138
+ Define_Tag: 'consume_token', -Required='ibytes', -required='temp';
139
+ Local: 'obytes' = bytes->(import8bits: #temp) &;
140
+ local: 'delimit' = (array: 9, 10, 13, 32, 44, 58, 93, 125); // \t\r\n ,:]}
141
+ While: (#delimit !>> (#temp := #ibytes->export8bits));
142
+ #obytes->(import8bits: #temp);
143
+ /While;
144
+ Local: 'output' = (String: #obytes);
145
+ If: (#output == 'true') || (#output == 'false');
146
+ Return: (Boolean: #output);
147
+ Else: (#output == 'null');
148
+ Return: Null;
149
+ Else: (String_IsNumeric: #output);
150
+ Return: (#output >> '.') ? (Decimal: #output) | (Integer: #output);
151
+ /If;
152
+ Return: @#output;
153
+ /Define_Tag;
154
+
155
+ Define_Tag: 'consume_array', -Required='ibytes';
156
+ Local: 'output' = array;
157
+ local: 'delimit' = (array: 9, 10, 13, 32, 44); // \t\r\n ,
158
+ local: 'temp' = 0;
159
+ While: ((#temp := #ibytes->export8bits) != 93); // ]
160
+ If: (#delimit >> #temp);
161
+ // Discard whitespace
162
+ Else: (#temp == 34); // "
163
+ #output->(insert: (consume_string: @#ibytes));
164
+ Else: (#temp == 91); // [
165
+ #output->(insert: (consume_array: @#ibytes));
166
+ Else: (#temp == 123); // {
167
+ #output->(insert: (consume_object: @#ibytes));
168
+ Else;
169
+ #output->(insert: (consume_token: @#ibytes, @#temp));
170
+ (#temp == 93) ? Loop_Abort;
171
+ /If;
172
+ /While;
173
+ Return: @#output;
174
+ /Define_Tag;
175
+
176
+ Define_Tag: 'consume_object', -Required='ibytes';
177
+ Local: 'output' = map;
178
+ local: 'delimit' = (array: 9, 10, 13, 32, 44); // \t\r\n ,
179
+ local: 'temp' = 0;
180
+ local: 'key' = null;
181
+ local: 'val' = null;
182
+ While: ((#temp := #ibytes->export8bits) != 125); // }
183
+ If: (#delimit >> #temp);
184
+ // Discard whitespace
185
+ Else: (#key !== null) && (#temp == 34); // "
186
+ #output->(insert: #key = (consume_string: @#ibytes));
187
+ #key = null;
188
+ Else: (#key !== null) && (#temp == 91); // [
189
+ #output->(insert: #key = (consume_array: @#ibytes));
190
+ #key = null;
191
+ Else: (#key !== null) && (#temp == 123); // {
192
+ #output->(insert: #key = (consume_object: @#ibytes));
193
+ #key = null;
194
+ Else: (#key !== null);
195
+ #output->(insert: #key = (consume_token: @#ibytes, @#temp));
196
+ (#temp == 125) ? Loop_abort;
197
+ #key = null;
198
+ Else;
199
+ #key = (consume_string: @#ibytes);
200
+ while(#delimit >> (#temp := #ibytes->export8bits));
201
+ /while;
202
+ #temp != 58 ? Loop_Abort;
203
+ /If;
204
+ /While;
205
+ If: (#output >> '__jsonclass__') && (#output->(Find: '__jsonclass__')->(isa: 'array')) && (#output->(Find: '__jsonclass__')->size >= 2) && (#output->(Find: '__jsonclass__')->First == 'deserialize');
206
+ Return: #output->(find: '__jsonclass__')->Second->First;
207
+ Else: (#output >> 'native') && (#output >> 'comment') && (#output->(find: 'comment') == 'http://www.lassosoft.com/json');
208
+ Return: #output->(find: 'native');
209
+ /If;
210
+ Return: @#output;
211
+ /Define_Tag;
212
+
213
+ Local: 'ibytes' = (bytes: #value);
214
+ Local: 'start' = 1;
215
+ #ibytes->removeLeading(BOM_UTF8);
216
+ Local: 'temp' = #ibytes->export8bits;
217
+ If: (#temp == 91); // [
218
+ Local: 'output' = (consume_array: @#ibytes);
219
+ Return: @#output;
220
+ Else: (#temp == 123); // {
221
+ Local: 'output' = (consume_object: @#ibytes);
222
+ Return: @#output;
223
+ /If;
224
+
225
+ /Define_Tag;
226
+
227
+ /If;
228
+
229
+ If: (Lasso_TagExists: 'Literal') == False;
230
+
231
+ Define_Type: 'Literal', 'String';
232
+ /Define_Type;
233
+
234
+ /If;
235
+
236
+ If: (Lasso_TagExists: 'Object') == False;
237
+
238
+ Define_Type: 'Object', 'Map';
239
+ /Define_Type;
240
+
241
+ /If;
242
+
243
+ If: (Lasso_TagExists: 'JSON_RPCCall') == False;
244
+
245
+ Define_Tag: 'RPCCall', -Namespace='JSON_',
246
+ -Required='method',
247
+ -Optional='params',
248
+ -Optional='id',
249
+ -Optional='host';
250
+
251
+ !(Local_Defined: 'host') ? Local: 'host' = 'http://localhost/lassoapps.8/rpc/rpc.lasso';
252
+ !(Local_Defined: 'id') ? Local: 'id' = Lasso_UniqueID;
253
+ Local: 'request' = (Map: 'method' = #method, 'params' = #params, 'id' = #id);
254
+ Local: 'request' = (Encode_JSON: #request);
255
+ Local: 'result' = (Include_URL: #host, -PostParams=#request);
256
+ Local: 'result' = (Decode_JSON: #result);
257
+ Return: @#result;
258
+
259
+ /Define_Tag;
260
+
261
+ /If;
262
+
263
+ If: (Lasso_TagExists: 'JSON_Records') == False;
264
+
265
+ Define_Tag: 'JSON_Records',
266
+ -Optional='KeyField',
267
+ -Optional='ReturnField',
268
+ -Optional='ExcludeField',
269
+ -Optional='Fields';
270
+
271
+ Local: '_fields' = (Local_Defined: 'fields') && #fields->(IsA: 'array') ? #fields | Field_Names;
272
+ Fail_If: #_fields->size == 0, -1, 'No fields found for [JSON_Records]';
273
+ Local: '_keyfield' = (Local: 'keyfield');
274
+ If: #_fields !>> #_keyfield;
275
+ Local: '_keyfield' = (KeyField_Name);
276
+ If: #_fields !>> #_keyfield;
277
+ Local: '_keyfield' = 'ID';
278
+ If: #_fields !>> #_keyfield;
279
+ Local: '_keyfield' = #_fields->First;
280
+ /If;
281
+ /If;
282
+ /If;
283
+ Local: '_index' = #_fields->(FindPosition: #_keyfield)->First;
284
+ Local: '_return' = (Local_Defined: 'returnfield') ? (Params->(Find: -ReturnField)->(ForEach: {Params->First = Params->First->Second; Return: True}) &) | @#_fields;
285
+ Local: '_exclude' = (Local_Defined: 'excludefield') ? (Params->(Find: -ExcludeField)->(ForEach: {Params->First = Params->First->Second; Return: True}) &) | Array;
286
+ Local: '_records' = Array;
287
+ Iterate: Records_Array, (Local: '_record');
288
+ Local: '_temp' = Map;
289
+ Iterate: #_fields, (Local: '_field');
290
+ ((#_return >> #_field) && (#_exclude !>> #_field)) ? #_temp->Insert(#_field = #_record->(Get: Loop_Count));
291
+ /Iterate;
292
+ #_records->Insert(#_temp);
293
+ /Iterate;
294
+ Local: '_output' = (Encode_JSON: (Object: 'error_msg'=Error_Msg, 'error_code'=Error_Code, 'found_count'=Found_Count, 'keyfield'=#_keyfield, 'rows'=#_records));
295
+ Return: @#_output;
296
+
297
+ /Define_Tag;
298
+
299
+ /If;
300
+
301
+ ?>