pygments.rb 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,286 @@
1
+ (* Internal Syntax *)
2
+ (* Author: Frank Pfenning, Carsten Schuermann *)
3
+ (* Modified: Roberto Virga *)
4
+
5
+ signature INTSYN =
6
+ sig
7
+
8
+ type cid = int (* Constant identifier *)
9
+ type mid = int (* Structure identifier *)
10
+ type csid = int (* CS module identifier *)
11
+
12
+
13
+ type FgnExp = exn (* foreign expression representation *)
14
+ exception UnexpectedFgnExp of FgnExp
15
+ (* raised by a constraint solver
16
+ if passed an incorrect arg *)
17
+ type FgnCnstr = exn (* foreign constraint representation *)
18
+ exception UnexpectedFgnCnstr of FgnCnstr
19
+ (* raised by a constraint solver
20
+ if passed an incorrect arg *)
21
+
22
+ (* Contexts *)
23
+
24
+ datatype 'a Ctx = (* Contexts *)
25
+ Null (* G ::= . *)
26
+ | Decl of 'a Ctx * 'a (* | G, D *)
27
+
28
+ val ctxPop : 'a Ctx -> 'a Ctx
29
+ val ctxLookup: 'a Ctx * int -> 'a
30
+ val ctxLength: 'a Ctx -> int
31
+
32
+ datatype Depend = (* Dependency information *)
33
+ No (* P ::= No *)
34
+ | Maybe (* | Maybe *)
35
+ | Meta (* | Meta *)
36
+
37
+ (* expressions *)
38
+
39
+ datatype Uni = (* Universes: *)
40
+ Kind (* L ::= Kind *)
41
+ | Type (* | Type *)
42
+
43
+ datatype Exp = (* Expressions: *)
44
+ Uni of Uni (* U ::= L *)
45
+ | Pi of (Dec * Depend) * Exp (* | Pi (D, P). V *)
46
+ | Root of Head * Spine (* | H @ S *)
47
+ | Redex of Exp * Spine (* | U @ S *)
48
+ | Lam of Dec * Exp (* | lam D. U *)
49
+ | EVar of Exp option ref * Dec Ctx * Exp * (Cnstr ref) list ref
50
+ (* | X<I> : G|-V, Cnstr *)
51
+ | EClo of Exp * Sub (* | U[s] *)
52
+ | AVar of Exp option ref (* | A<I> *)
53
+
54
+ | FgnExp of csid * FgnExp (* | (foreign expression) *)
55
+
56
+ | NVar of int (* | n (linear,
57
+ fully applied variable
58
+ used in indexing *)
59
+
60
+ and Head = (* Head: *)
61
+ BVar of int (* H ::= k *)
62
+ | Const of cid (* | c *)
63
+ | Proj of Block * int (* | #k(b) *)
64
+ | Skonst of cid (* | c# *)
65
+ | Def of cid (* | d (strict) *)
66
+ | NSDef of cid (* | d (non strict) *)
67
+ | FVar of string * Exp * Sub (* | F[s] *)
68
+ | FgnConst of csid * ConDec (* | (foreign constant) *)
69
+
70
+ and Spine = (* Spines: *)
71
+ Nil (* S ::= Nil *)
72
+ | App of Exp * Spine (* | U ; S *)
73
+ | SClo of Spine * Sub (* | S[s] *)
74
+
75
+ and Sub = (* Explicit substitutions: *)
76
+ Shift of int (* s ::= ^n *)
77
+ | Dot of Front * Sub (* | Ft.s *)
78
+
79
+ and Front = (* Fronts: *)
80
+ Idx of int (* Ft ::= k *)
81
+ | Exp of Exp (* | U *)
82
+ | Axp of Exp (* | U *)
83
+ | Block of Block (* | _x *)
84
+ | Undef (* | _ *)
85
+
86
+ and Dec = (* Declarations: *)
87
+ Dec of string option * Exp (* D ::= x:V *)
88
+ | BDec of string option * (cid * Sub) (* | v:l[s] *)
89
+ | ADec of string option * int (* | v[^-d] *)
90
+ | NDec of string option
91
+
92
+ and Block = (* Blocks: *)
93
+ Bidx of int (* b ::= v *)
94
+ | LVar of Block option ref * Sub * (cid * Sub)
95
+ (* | L(l[^k],t) *)
96
+ | Inst of Exp list (* | U1, ..., Un *)
97
+ (* It would be better to consider having projections count
98
+ like substitutions, then we could have Inst of Sub here,
99
+ which would simplify a lot of things.
100
+
101
+ I suggest however to wait until the next big overhaul
102
+ of the system -- cs *)
103
+
104
+
105
+ (* | BClo of Block * Sub (* | b[s] *) *)
106
+
107
+ (* constraints *)
108
+
109
+ and Cnstr = (* Constraint: *)
110
+ Solved (* Cnstr ::= solved *)
111
+ | Eqn of Dec Ctx * Exp * Exp (* | G|-(U1 == U2) *)
112
+ | FgnCnstr of csid * FgnCnstr (* | (foreign) *)
113
+
114
+ and Status = (* Status of a constant: *)
115
+ Normal (* inert *)
116
+ | Constraint of csid * (Dec Ctx * Spine * int -> Exp option)
117
+ (* acts as constraint *)
118
+ | Foreign of csid * (Spine -> Exp) (* is converted to foreign *)
119
+
120
+ and FgnUnify = (* Result of foreign unify *)
121
+ Succeed of FgnUnifyResidual list
122
+ (* succeed with a list of residual operations *)
123
+ | Fail
124
+
125
+ and FgnUnifyResidual =
126
+ Assign of Dec Ctx * Exp * Exp * Sub
127
+ (* perform the assignment G |- X = U [ss] *)
128
+ | Delay of Exp * Cnstr ref
129
+ (* delay cnstr, associating it with all the rigid EVars in U *)
130
+
131
+ (* Global signature *)
132
+
133
+ and ConDec = (* Constant declaration *)
134
+ ConDec of string * mid option * int * Status
135
+ (* a : K : kind or *)
136
+ * Exp * Uni (* c : A : type *)
137
+ | ConDef of string * mid option * int (* a = A : K : kind or *)
138
+ * Exp * Exp * Uni (* d = M : A : type *)
139
+ * Ancestor (* Ancestor info for d or a *)
140
+ | AbbrevDef of string * mid option * int
141
+ (* a = A : K : kind or *)
142
+ * Exp * Exp * Uni (* d = M : A : type *)
143
+ | BlockDec of string * mid option (* %block l : SOME G1 PI G2 *)
144
+ * Dec Ctx * Dec list
145
+ | BlockDef of string * mid option * cid list
146
+ (* %block l = (l1 | ... | ln) *)
147
+ | SkoDec of string * mid option * int (* sa: K : kind or *)
148
+ * Exp * Uni (* sc: A : type *)
149
+
150
+ and Ancestor = (* Ancestor of d or a *)
151
+ Anc of cid option * int * cid option (* head(expand(d)), height, head(expand[height](d)) *)
152
+ (* NONE means expands to {x:A}B *)
153
+
154
+ datatype StrDec = (* Structure declaration *)
155
+ StrDec of string * mid option
156
+
157
+ (* Form of constant declaration *)
158
+ datatype ConDecForm =
159
+ FromCS (* from constraint domain *)
160
+ | Ordinary (* ordinary declaration *)
161
+ | Clause (* %clause declaration *)
162
+
163
+ (* Type abbreviations *)
164
+ type dctx = Dec Ctx (* G = . | G,D *)
165
+ type eclo = Exp * Sub (* Us = U[s] *)
166
+ type bclo = Block * Sub (* Bs = B[s] *)
167
+ type cnstr = Cnstr ref
168
+
169
+ exception Error of string (* raised if out of space *)
170
+
171
+ (* standard operations on foreign expressions *)
172
+ structure FgnExpStd : sig
173
+ (* convert to internal syntax *)
174
+ structure ToInternal : FGN_OPN where type arg = unit
175
+ where type result = Exp
176
+
177
+ (* apply function to subterms *)
178
+ structure Map : FGN_OPN where type arg = Exp -> Exp
179
+ where type result = Exp
180
+
181
+ (* apply function to subterms, for effect *)
182
+ structure App : FGN_OPN where type arg = Exp -> unit
183
+ where type result = unit
184
+
185
+ (* test for equality *)
186
+ structure EqualTo : FGN_OPN where type arg = Exp
187
+ where type result = bool
188
+
189
+ (* unify with another term *)
190
+ structure UnifyWith : FGN_OPN where type arg = Dec Ctx * Exp
191
+ where type result = FgnUnify
192
+
193
+ (* fold a function over the subterms *)
194
+ val fold : (csid * FgnExp) -> (Exp * 'a -> 'a) -> 'a -> 'a
195
+ end
196
+
197
+ (* standard operations on foreign constraints *)
198
+ structure FgnCnstrStd : sig
199
+ (* convert to internal syntax *)
200
+ structure ToInternal : FGN_OPN where type arg = unit
201
+ where type result = (Dec Ctx * Exp) list
202
+
203
+ (* awake *)
204
+ structure Awake : FGN_OPN where type arg = unit
205
+ where type result = bool
206
+
207
+ (* simplify *)
208
+ structure Simplify : FGN_OPN where type arg = unit
209
+ where type result = bool
210
+ end
211
+
212
+ val conDecName : ConDec -> string
213
+ val conDecParent : ConDec -> mid option
214
+ val conDecImp : ConDec -> int
215
+ val conDecStatus : ConDec -> Status
216
+ val conDecType : ConDec -> Exp
217
+ val conDecBlock : ConDec -> dctx * Dec list
218
+ val conDecUni : ConDec -> Uni
219
+
220
+ val strDecName : StrDec -> string
221
+ val strDecParent : StrDec -> mid option
222
+
223
+ val sgnReset : unit -> unit
224
+ val sgnSize : unit -> cid * mid
225
+
226
+ val sgnAdd : ConDec -> cid
227
+ val sgnLookup: cid -> ConDec
228
+ val sgnApp : (cid -> unit) -> unit
229
+
230
+ val sgnStructAdd : StrDec -> mid
231
+ val sgnStructLookup : mid -> StrDec
232
+
233
+ val constType : cid -> Exp (* type of c or d *)
234
+ val constDef : cid -> Exp (* definition of d *)
235
+ val constImp : cid -> int
236
+ val constStatus : cid -> Status
237
+ val constUni : cid -> Uni
238
+ val constBlock : cid -> dctx * Dec list
239
+
240
+ (* Declaration Contexts *)
241
+
242
+ val ctxDec : dctx * int -> Dec (* get variable declaration *)
243
+ val blockDec : dctx * Block * int -> Dec
244
+
245
+ (* Explicit substitutions *)
246
+
247
+ val id : Sub (* id *)
248
+ val shift : Sub (* ^ *)
249
+ val invShift : Sub (* ^-1 *)
250
+
251
+ val bvarSub : int * Sub -> Front (* k[s] *)
252
+ val frontSub : Front * Sub -> Front (* H[s] *)
253
+ val decSub : Dec * Sub -> Dec (* x:V[s] *)
254
+ val blockSub : Block * Sub -> Block (* B[s] *)
255
+
256
+ val comp : Sub * Sub -> Sub (* s o s' *)
257
+ val dot1 : Sub -> Sub (* 1 . (s o ^) *)
258
+ val invDot1 : Sub -> Sub (* (^ o s) o ^-1) *)
259
+
260
+ (* EVar related functions *)
261
+
262
+ val newEVar : dctx * Exp -> Exp (* creates X:G|-V, [] *)
263
+ val newAVar : unit -> Exp (* creates A (bare) *)
264
+ val newTypeVar : dctx -> Exp (* creates X:G|-type, [] *)
265
+ val newLVar : Sub * (cid * Sub) -> Block
266
+ (* creates B:(l[^k],t) *)
267
+
268
+ (* Definition related functions *)
269
+ val headOpt : Exp -> Head option
270
+ val ancestor : Exp -> Ancestor
271
+ val defAncestor : cid -> Ancestor
272
+
273
+ (* Type related functions *)
274
+
275
+ (* Not expanding type definitions *)
276
+ val targetHeadOpt : Exp -> Head option (* target type family or NONE *)
277
+ val targetHead : Exp -> Head (* target type family *)
278
+
279
+ (* Expanding type definitions *)
280
+ val targetFamOpt : Exp -> cid option (* target type family or NONE *)
281
+ val targetFam : Exp -> cid (* target type family *)
282
+
283
+ (* Used in Flit *)
284
+ val rename : cid * string -> unit
285
+
286
+ end; (* signature INTSYN *)
@@ -1,5 +1,6 @@
1
1
  regression=# select foo;
2
2
  ERROR: column "foo" does not exist
3
+ CONTEXT: PL/pgSQL function "test1" while casting return value to function's return type
3
4
  LINE 1: select foo;
4
5
  ^
5
6
  regression=# \q
@@ -0,0 +1,93 @@
1
+ import re
2
+
3
+ for x in lines("myfile.txt"):
4
+ if x =~ re"(\w+)=(.*)":
5
+ echo "Key: ", matches[0],
6
+ " Value: ", matches[1]
7
+
8
+ Echo("What's your name? ")
9
+ var name: string = readLine(stdin)
10
+ if name == "":
11
+ echo("Poor soul, you lost your name?")
12
+ elif name == "name":
13
+ echo("Very funny, your name is name.")
14
+ else:
15
+ Echo("Hi, ", name, "!")
16
+
17
+ var name = readLine(stdin)
18
+ case name
19
+ of "":
20
+ echo("Poor soul, you lost your name?")
21
+ of "name":
22
+ echo("Very funny, your name is name.")
23
+ else:
24
+ Echo("Hi, ", name, "!")
25
+
26
+ from strutils import parseInt
27
+
28
+ Echo("A number please: ")
29
+ var n = parseInt(readLine(stdin))
30
+ case n
31
+ of 0..2, 4..7: Echo("The number is in the set: {0, 1, 2, 4, 5, 6, 7}")
32
+ of 3, 8: Echo("The number is 3 or 8")
33
+
34
+ Echo("Counting to 10: ")
35
+ var i = 1
36
+ while i <= 10:
37
+ Echo($i)
38
+ inc(i)
39
+
40
+ proc yes(question: string): bool =
41
+ Echo(question, " (y/n)")
42
+ while true:
43
+ case readLine(stdin)
44
+ of "y", "Y", "yes", "Yes": return true
45
+ of "n", "N", "no", "No": return false
46
+ else: Echo("Please be clear: yes or no")
47
+
48
+ proc even(n: int): bool
49
+
50
+ proc odd(n: int): bool =
51
+ if n == 1: return true
52
+ else: return even(n-1)
53
+
54
+ iterator countup(a, b: int): int =
55
+ var res = a
56
+ while res <= b:
57
+ yield res
58
+ inc(res)
59
+
60
+ type
61
+ TPerson = object of TObject
62
+ name*: string # the * means that `name` is accessible from other modules
63
+ age: int # no * means that the field is hidden from other modules
64
+
65
+ TStudent = object of TPerson # TStudent inherits from TPerson
66
+ id: int # with an id field
67
+
68
+ var
69
+ student: TStudent
70
+ person: TPerson
71
+ assert(student is TStudent)
72
+
73
+ echo({'a', 'b', 'c'}.card)
74
+ stdout.writeln("Hallo")
75
+ var
76
+ f: TFile
77
+ if open(f, "numbers.txt"):
78
+ try:
79
+ var a = readLine(f)
80
+ var b = readLine(f)
81
+ echo("sum: " & $(parseInt(a) + parseInt(b)))
82
+ except EOverflow:
83
+ echo("overflow!")
84
+ except EInvalidValue:
85
+ echo("could not convert string to integer")
86
+ except EIO:
87
+ echo("IO error!")
88
+ except:
89
+ echo("Unknown exception!")
90
+ # reraise the unknown exception:
91
+ raise
92
+ finally:
93
+ close(f)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pygments.rb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aman Gupta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-30 00:00:00 -05:00
18
+ date: 2011-09-22 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -245,6 +245,7 @@ files:
245
245
  - vendor/pygments-main/tests/examplefiles/example.rb
246
246
  - vendor/pygments-main/tests/examplefiles/example.rhtml
247
247
  - vendor/pygments-main/tests/examplefiles/example.sh-session
248
+ - vendor/pygments-main/tests/examplefiles/example.sml
248
249
  - vendor/pygments-main/tests/examplefiles/example.weechatlog
249
250
  - vendor/pygments-main/tests/examplefiles/example.xhtml
250
251
  - vendor/pygments-main/tests/examplefiles/example.yaml
@@ -264,6 +265,8 @@ files:
264
265
  - vendor/pygments-main/tests/examplefiles/import.hs
265
266
  - vendor/pygments-main/tests/examplefiles/intro.ik
266
267
  - vendor/pygments-main/tests/examplefiles/ints.php
268
+ - vendor/pygments-main/tests/examplefiles/intsyn.fun
269
+ - vendor/pygments-main/tests/examplefiles/intsyn.sig
267
270
  - vendor/pygments-main/tests/examplefiles/irb_heredoc
268
271
  - vendor/pygments-main/tests/examplefiles/java.properties
269
272
  - vendor/pygments-main/tests/examplefiles/jbst_example1.jbst
@@ -341,6 +344,7 @@ files:
341
344
  - vendor/pygments-main/tests/examplefiles/test.mod
342
345
  - vendor/pygments-main/tests/examplefiles/test.moo
343
346
  - vendor/pygments-main/tests/examplefiles/test.myt
347
+ - vendor/pygments-main/tests/examplefiles/test.nim
344
348
  - vendor/pygments-main/tests/examplefiles/test.pas
345
349
  - vendor/pygments-main/tests/examplefiles/test.php
346
350
  - vendor/pygments-main/tests/examplefiles/test.plot
@@ -377,7 +381,7 @@ files:
377
381
  - vendor/pygments-main/tests/test_token.py
378
382
  - vendor/pygments-main/tests/test_using_api.py
379
383
  - vendor/pygments-main/tests/test_util.py
380
- has_rdoc: true
384
+ has_rdoc: false
381
385
  homepage: http://github.com/tmm1/pygments.rb
382
386
  licenses: []
383
387
 
@@ -407,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
411
  requirements: []
408
412
 
409
413
  rubyforge_project:
410
- rubygems_version: 1.5.2
414
+ rubygems_version: 1.6.2
411
415
  signing_key:
412
416
  specification_version: 3
413
417
  summary: pygments wrapper for ruby