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,9 @@
1
+ 10 rem cbm basic v2 example
2
+ 20 rem comment with keywords: for, data
3
+ 30 dim a$(20)
4
+ 35 rem the typical space efficient form of leaving spaces out:
5
+ 40 fort=0to15:poke646,t:print"{revers on} ";:next
6
+ 50 geta$:ifa$=chr$(0):goto40
7
+ 55 rem it is legal to omit the closing " on line end
8
+ 60 print"{white}":print"bye...
9
+ 70 end
@@ -1,12 +1,26 @@
1
+ module: sample
2
+ comment: for make sure that does not highlight per word.
3
+ and it continues on to the next line.
4
+
1
5
  define class <car> (<object>)
2
6
  slot serial-number :: <integer> = unique-serial-number();
3
- slot model-name :: <string>,
7
+ constant slot model-name :: <string>,
4
8
  required-init-keyword: model:;
5
- slot has-sunroof? :: <boolean>,
9
+ each-subclass slot has-sunroof? :: <boolean>,
6
10
  init-keyword: sunroof?:,
7
11
  init-value: #f;
12
+ keyword foo:;
13
+ required keyword bar:;
8
14
  end class <car>;
9
15
 
16
+ define class <flying-car> (<car>)
17
+ end class <flying-car>;
18
+
19
+ let flying-car = make(<flying-car>);
20
+ let car? :: <car?> = #f;
21
+ let prefixed-car :: <vehicles/car> = #f;
22
+ let model :: <car-911> = #f;
23
+
10
24
  define constant $empty-string = "";
11
25
  define constant $escaped-backslash = '\\';
12
26
  define constant $escaped-single-quote = '\'';
@@ -31,10 +45,81 @@ define method foo() => _ :: <boolean>;
31
45
  #t
32
46
  end method;
33
47
 
34
- define method \+()
35
- end;
48
+ define method \+
49
+ (offset1 :: <time-offset>, offset2 :: <time-offset>)
50
+ => (sum :: <time-offset>)
51
+ let sum = offset1.total-seconds + offset2.total-seconds;
52
+ make(<time-offset>, total-seconds: sum);
53
+ end method \+;
54
+
55
+ define method bar ()
56
+ 1 | 2 & 3
57
+ end
58
+
59
+ if (bar)
60
+ 1
61
+ elseif (foo)
62
+ 2
63
+ else
64
+ 3
65
+ end if;
66
+
67
+ select (foo by instance?)
68
+ <integer> => 1
69
+ otherwise => 3
70
+ end select;
71
+
72
+ /* multi
73
+ line
74
+ comment
75
+ */
76
+
77
+ /* multi line comments
78
+ /* can be */
79
+ nested */
36
80
 
37
81
  define constant $symbol = #"hello";
38
82
  define variable *vector* = #[3.5, 5]
39
83
  define constant $list = #(1, 2);
40
84
  define constant $pair = #(1 . "foo")
85
+
86
+ let octal-number = #o238;
87
+ let hex-number = #x3890ADEF;
88
+ let binary-number = #b1010;
89
+ let float-exponent = 3.5e10;
90
+
91
+ block (return)
92
+ with-lock (lock)
93
+ return();
94
+ end;
95
+ exception (e :: <error>)
96
+ format-out("Oh no");
97
+ cleanup
98
+ return();
99
+ afterwards
100
+ format-out("Hello");
101
+ end;
102
+
103
+ define macro repeat
104
+ { repeat ?:body end }
105
+ => { block (?=stop!)
106
+ local method again() ?body; again() end;
107
+ again();
108
+ end }
109
+ end macro repeat;
110
+
111
+ define macro with-decoded-seconds
112
+ {
113
+ with-decoded-seconds
114
+ (?max:variable, ?min:variable, ?sec:variable = ?time:expression)
115
+ ?:body
116
+ end
117
+ }
118
+ => {
119
+ let (?max, ?min, ?sec) = decode-total-seconds(?time);
120
+ ?body
121
+ }
122
+ end macro;
123
+
124
+ let x = "This size call should be seen as a builtin despite the odd case.".siZe;
125
+
@@ -0,0 +1,78 @@
1
+ \name{foo}
2
+ \alias{foo}
3
+ % I'm a comment
4
+ \title{The foo function}
5
+
6
+ \description{It doesn't do much}
7
+
8
+ \usage{
9
+ foo(x, y)
10
+ }
11
+
12
+ \arguments{
13
+ \item{x}{A number}
14
+ \item{y}{Another number}
15
+ }
16
+ \details{
17
+ I just adds \code{x} and \code{y},
18
+ }
19
+ \value{\code{numeric}. The sum of \code{x} and \code{y}.}
20
+ \references{
21
+ \href{http://en.wikipedia.org/wiki/Sum}{Sum}
22
+ }
23
+ \author{
24
+ Anonymous
25
+ }
26
+ \note{
27
+ Lorem ipsum \dots \R \emph{emp}, \strong{strong}, \bold{bold},
28
+ \sQuote{single quotes}, \dQuote{double quotes}, \code{code},
29
+ \preformatted{x <- 2 + 2}, \kbd{type this}, \samp{literal seq},
30
+ \pkg{base}, \file{foo.txt}, \email{email@hostname},
31
+ \url{http://cran.r-project.org/}, \var{foo}, \env{HOME},
32
+ \option{-d}, \dfn{something new}, \acronym{GNU}.
33
+
34
+ Escaped symbols: \\ \{ \} \% not comment. \\NotAMacro.
35
+
36
+ \tabular{rlll}{
37
+ [,1] \tab alpha \tab numeric \tab A (ppb)\cr
38
+ [,2] \tab bravo \tab integer \tab B \cr
39
+ [,3] \tab charlie \tab character \tab C \cr
40
+ }
41
+ \enumerate{
42
+ \item delta
43
+ \item echo
44
+ }
45
+ \itemize{
46
+ \item foxtrot
47
+ \item golf
48
+ }
49
+
50
+ \deqn{p(x; \mu, \sigma^2) = \frac{1}{\sigma \sqrt{2 \pi}} \exp \frac{-(x - \mu)^2}{2 \sigma}{%
51
+ p(\mu; x) = 1/\sigma (2 \pi)^(-1/2) exp( -(x - \mu)^2 / (2 \sigma)) }
52
+ for \eqn{x = 0, 1, 2, \ldots}.
53
+
54
+ \if{latex}{\out{\beta}}\ifelse{html}{\out{&beta;}}{beta}
55
+
56
+ #ifdef unix
57
+ Now windows
58
+ #endif
59
+ #ifndef windows
60
+ Using windows
61
+ #endif
62
+
63
+ }
64
+ \section{Misc}{
65
+ Stuff.
66
+ }
67
+
68
+ \seealso{
69
+ \code{\link{sum}}
70
+ }
71
+ \examples{
72
+ x <- 1
73
+ y <- 2
74
+ z <- foo(x, y)
75
+ \dontrun{plot(z)}
76
+ \dontshow{log(x)}
77
+ }
78
+ \keyword{arith}
@@ -0,0 +1,54 @@
1
+ # Alligators: multinomial - logistic regression
2
+ # http://www.openbugs.info/Examples/Aligators.html
3
+ model {
4
+ # PRIORS
5
+ alpha[1] <- 0; # zero contrast for baseline food
6
+ for (k in 2 : K) {
7
+ alpha[k] ~ dnorm(0, 0.00001) # vague priors
8
+ }
9
+ # Loop around lakes:
10
+ for (k in 1 : K){
11
+ beta[1, k] <- 0
12
+ } # corner-point contrast with first lake
13
+ for (i in 2 : I) {
14
+ beta[i, 1] <- 0 ; # zero contrast for baseline food
15
+ for (k in 2 : K){
16
+ beta[i, k] ~ dnorm(0, 0.00001) # vague priors
17
+ }
18
+ }
19
+ # Loop around sizes:
20
+ for (k in 1 : K){
21
+ gamma[1, k] <- 0 # corner-point contrast with first size
22
+ }
23
+ for (j in 2 : J) {
24
+ gamma[j, 1] <- 0 ; # zero contrast for baseline food
25
+ for ( k in 2 : K){
26
+ gamma[j, k] ~ dnorm(0, 0.00001) # vague priors
27
+ }
28
+ }
29
+
30
+ # LIKELIHOOD
31
+ for (i in 1 : I) { # loop around lakes
32
+ for (j in 1 : J) { # loop around sizes
33
+
34
+ # Fit standard Poisson regressions relative to baseline
35
+ lambda[i, j] ~ dflat() # vague priors
36
+ for (k in 1 : K) { # loop around foods
37
+ X[i, j, k] ~ dpois(mu[i, j, k])
38
+ log(mu[i, j, k]) <- lambda[i, j] + alpha[k] + beta[i, k] + gamma[j, k]
39
+ culmative.X[i, j, k] <- culmative(X[i, j, k], X[i, j, k])
40
+ }
41
+ }
42
+ }
43
+
44
+ # TRANSFORM OUTPUT TO ENABLE COMPARISON
45
+ # WITH AGRESTI'S RESULTS
46
+ for (k in 1 : K) { # loop around foods
47
+ for (i in 1 : I) { # loop around lakes
48
+ b[i, k] <- beta[i, k] - mean(beta[, k]); # sum to zero constraint
49
+ }
50
+ for (j in 1 : J) { # loop around sizes
51
+ g[j, k] <- gamma[j, k] - mean(gamma[, k]); # sum to zero constraint
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,52 @@
1
+ import ceylon.language { parseInteger }
2
+
3
+ doc "A top-level function,
4
+ with multi-line documentation."
5
+ void topLevel(String? a, Integer b=5, String* seqs) {
6
+ function nested(String s) {
7
+ print(s[1..2]);
8
+ return true;
9
+ }
10
+ for (s in seqs.filter((String x) => x.size > 2)) {
11
+ nested(s);
12
+ }
13
+ value uppers = seqs.map((String x) {
14
+ return x.uppercased;
15
+ });
16
+ String|Null z = a;
17
+ {Integer+} ints = { 1, 2, 3, 4, 5 };
18
+ value numbers = [ 1, #ffff, #ffff_ffff, $10101010, $1010_1010_1010_1010,
19
+ 123_456_789 ];
20
+ value chars = ['a', '\{#ffff}' ];
21
+ }
22
+
23
+ shared class Example_1<Element>(name, element) satisfies Comparable<Example_1<Element>>
24
+ given Element satisfies Comparable<Element> {
25
+ shared String name;
26
+ shared Element element;
27
+ shared [Integer,String] tuple = [1, "2"];
28
+ shared late String lastName;
29
+ variable Integer cnt = 0;
30
+
31
+ shared Integer count => cnt;
32
+ assign count {
33
+ assert(count >= cnt);
34
+ cnt = count;
35
+ }
36
+
37
+ shared actual Comparison compare(Example_1<Element> other) {
38
+ return element <=> other.element;
39
+ }
40
+
41
+ shared actual String string {
42
+ return "Example with ``element.string``";
43
+ }
44
+ }
45
+
46
+ Example_1<Integer> instance = Example_1 {
47
+ element = 5;
48
+ name = "Named args call \{#0060}";
49
+ };
50
+
51
+ object example1 extends Example_1<Integer>("object", 5) {
52
+ }
@@ -0,0 +1,33 @@
1
+
2
+ /// @section StringLiteralRef
3
+
4
+ record StringLiteralRef (
5
+ sizep : Pointer[SizeT],
6
+ );
7
+
8
+
9
+ /// @section predicates
10
+
11
+ overload ContiguousSequence?(#StringLiteralRef) : Bool = true;
12
+ [s when StringLiteral?(s)]
13
+ overload ContiguousSequence?(#Static[s]) : Bool = true;
14
+
15
+
16
+
17
+ /// @section size, begin, end, index
18
+
19
+ forceinline overload size(a:StringLiteralRef) = a.sizep^;
20
+
21
+ forceinline overload begin(a:StringLiteralRef) : Pointer[Char] = Pointer[Char](a.sizep + 1);
22
+ forceinline overload end(a:StringLiteralRef) = begin(a) + size(a);
23
+
24
+ [I when Integer?(I)]
25
+ forceinline overload index(a:StringLiteralRef, i:I) : ByRef[Char] {
26
+ assert["boundsChecks"](i >= 0 and i < size(a), "StringLiteralRef index out of bounds");
27
+ return ref (begin(a) + i)^;
28
+ }
29
+
30
+ foo() = """
31
+ long\tlong
32
+ story
33
+ """
@@ -0,0 +1,3556 @@
1
+ IDENTIFICATION DIVISION.
2
+ PROGRAM-ID. OCic.
3
+ *****************************************************************
4
+ ** This program provides a Textual User Interface (TUI) to the **
5
+ ** process of compiling and (optionally) executing an OpenCOBOL**
6
+ ** program. **
7
+ ** **
8
+ ** This programs execution syntax is as follows: **
9
+ ** **
10
+ ** ocic <program-path-and-filename> [ <switch>... ] **
11
+ ** **
12
+ ** Once executed, a display screen will be presented showing **
13
+ ** the compilation options that will be used. The user will **
14
+ ** have the opportunity to change options, specify new ones **
15
+ ** and specify any program execution arguments to be used if **
16
+ ** you select the "Execute" option. When you press the Enter **
17
+ ** key the program will be compiled. **
18
+ ** **
19
+ ** The SCREEN SECTION contains an image of the screen. **
20
+ ** **
21
+ ** The "010-Parse-Args" section in the PROCEDURE DIVISION has **
22
+ ** documentation on switches and their function. **
23
+ *****************************************************************
24
+ ** **
25
+ ** AUTHOR: GARY L. CUTLER **
26
+ ** CutlerGL@gmail.com **
27
+ ** Copyright (C) 2009-2010, Gary L. Cutler, GPL **
28
+ ** **
29
+ ** DATE-WRITTEN: June 14, 2009 **
30
+ ** **
31
+ *****************************************************************
32
+ ** Note: Depending on which extended DISPLAY handler you're **
33
+ ** using (PDCurses, Curses, ...), you may need to un- **
34
+ ** comment any source lines tagged with "SCROLL" in cols **
35
+ ** 1-6 in order to have error messages scroll properly **
36
+ ** in the OCic shell window. **
37
+ *****************************************************************
38
+ ** DATE CHANGE DESCRIPTION **
39
+ ** ====== ==================================================== **
40
+ ** GC0609 Don't display compiler messages file if compilation **
41
+ ** Is successful. Also don't display messages if the **
42
+ ** output file is busy (just put a message on the **
43
+ ** screen, leave the OC screen up & let the user fix **
44
+ ** the problem & resubmit. **
45
+ ** GC0709 When 'EXECUTE' is selected, a 'FILE BUSY' error will **
46
+ ** still cause the (old) executable to be launched. **
47
+ ** Also, the 'EXTRA SWITCHES' field is being ignored. **
48
+ ** Changed the title bar to lowlighted reverse video & **
49
+ ** the message area to highlighted reverse-video. **
50
+ ** GC0809 Add a SPACE in from of command-line args when **
51
+ ** executing users program. Add a SPACE after the **
52
+ ** -ftraceall switch when building cobc command. **
53
+ ** GC0909 Convert to work on Cygwin/Linux as well as MinGW **
54
+ ** GC0310 Virtualized the key codes for S-F1 thru S-F7 as they **
55
+ ** differ depending upon whether PDCurses or NCurses is **
56
+ ** being used. **
57
+ ** GC0410 Introduced the cross-reference and source listing **
58
+ ** features. Also fixed a bug in @EXTRA switch proces- **
59
+ ** sing where garbage will result if more than the **
60
+ ** @EXTRA switch is specified. **
61
+ *****************************************************************
62
+ ENVIRONMENT DIVISION.
63
+ CONFIGURATION SECTION.
64
+ REPOSITORY.
65
+ FUNCTION ALL INTRINSIC.
66
+ INPUT-OUTPUT SECTION.
67
+ FILE-CONTROL.
68
+ SELECT Bat-File ASSIGN TO Bat-File-Name
69
+ ORGANIZATION IS LINE SEQUENTIAL.
70
+
71
+ SELECT Cobc-Output ASSIGN TO Cobc-Output-File
72
+ ORGANIZATION IS LINE SEQUENTIAL.
73
+
74
+ SELECT Source-Code ASSIGN TO File-Name
75
+ ORGANIZATION IS LINE SEQUENTIAL
76
+ FILE STATUS IS FSM-Status.
77
+ DATA DIVISION.
78
+ FILE SECTION.
79
+ FD Bat-File.
80
+ 01 Bat-File-Rec PIC X(2048).
81
+
82
+ FD Cobc-Output.
83
+ 01 Cobc-Output-Rec PIC X(256).
84
+
85
+ FD Source-Code.
86
+ 01 Source-Code-Record PIC X(80).
87
+
88
+ WORKING-STORAGE SECTION.
89
+ COPY screenio.
90
+
91
+ 01 Bat-File-Name PIC X(256).
92
+
93
+ GC0909 01 Cmd PIC X(512).
94
+
95
+ 01 Cobc-Cmd PIC X(256).
96
+
97
+ 01 Cobc-Output-File PIC X(256).
98
+
99
+ 01 Command-Line-Args PIC X(256).
100
+
101
+ 01 Config-File PIC X(12).
102
+
103
+ GC0310 01 Config-Keys.
104
+ GC0310 05 CK-S-F1 PIC 9(4).
105
+ GC0310 05 CK-S-F2 PIC 9(4).
106
+ GC0310 05 CK-S-F3 PIC 9(4).
107
+ GC0310 05 CK-S-F4 PIC 9(4).
108
+ GC0310 05 CK-S-F5 PIC 9(4).
109
+ GC0310 05 CK-S-F6 PIC 9(4).
110
+ GC0310 05 CK-S-F7 PIC 9(4).
111
+
112
+ GC0909 01 Dir-Char PIC X(1).
113
+
114
+ 01 Dummy PIC X(1).
115
+
116
+ 01 Env-TEMP PIC X(256).
117
+
118
+ 01 File-Name.
119
+ 05 FN-Char OCCURS 256 TIMES PIC X(1).
120
+
121
+ 01 File-Status-Message.
122
+ 05 FILLER PIC X(13) VALUE 'Status Code: '.
123
+ 05 FSM-Status PIC 9(2).
124
+ 05 FILLER PIC X(11) VALUE ', Meaning: '.
125
+ 05 FSM-Msg PIC X(25).
126
+
127
+ 01 Flags.
128
+ 05 F-Compilation-Succeeded PIC X(1).
129
+ 88 88-Compile-OK VALUE 'Y'.
130
+ GC0909 88 88-Compile-OK-Warn VALUE 'W'.
131
+ 88 88-Compile-Failed VALUE 'N'.
132
+ GC0609 05 F-Complete PIC X(1).
133
+ GC0609 88 88-Complete VALUE 'Y'.
134
+ GC0609 88 88-Not-Complete VALUE 'N'.
135
+ GC0809 05 F-IDENT-DIVISION PIC X(1).
136
+ GC0809 88 88-1st-Prog-Complete VALUE 'Y'.
137
+ GC0809 88 88-More-To-1st-Prog VALUE 'N'.
138
+ 05 F-LINKAGE-SECTION PIC X(1).
139
+ 88 88-Compile-As-Subpgm VALUE 'Y'.
140
+ 88 88-Compile-As-Mainpgm VALUE 'N'.
141
+ 05 F-No-Switch-Changes PIC X(1).
142
+ 88 88-No-Switch-Changes VALUE 'Y'.
143
+ 88 88-Switch-Changes VALUE 'N'.
144
+ GC0709 05 F-Output-File-Busy PIC X(1).
145
+ GC0709 88 88-Output-File-Busy VALUE 'Y'.
146
+ GC0709 88 88-Output-File-Avail VALUE 'N'.
147
+ GC0809 05 F-Source-Record-Type PIC X(1).
148
+ GC0809 88 88-Source-Rec-Linkage VALUE 'L'.
149
+ GC0809 88 88-Source-Rec-Ident VALUE 'I'.
150
+ GC0809 88 88-Source-Rec-IgnoCOB-COLOR-RED VALUE ' '.
151
+ 05 F-Switch-Error PIC X(1).
152
+ 88 88-Switch-Is-Bad VALUE 'Y'.
153
+ 88 88-Switch-Is-Good VALUE 'N'.
154
+
155
+ GC0909 01 Horizontal-Line PIC X(80).
156
+ GC0909
157
+ 01 I USAGE BINARY-LONG.
158
+
159
+ 01 J USAGE BINARY-LONG.
160
+
161
+ GC0909 01 MS USAGE BINARY-LONG.
162
+
163
+ GC0909 01 ML USAGE BINARY-LONG.
164
+
165
+ 01 OC-Compiled PIC XXXX/XX/XXBXX/XX.
166
+
167
+ GC0909 01 OS-Type USAGE BINARY-LONG.
168
+ GC0909 88 OS-Unknown VALUE 0.
169
+ GC0909 88 OS-Windows VALUE 1.
170
+ GC0909 88 OS-Cygwin VALUE 2.
171
+ GC0909 88 OS-UNIX VALUE 3.
172
+
173
+ GC0909 01 OS-Type-Literal PIC X(7).
174
+
175
+ 01 Output-Message PIC X(80).
176
+
177
+ 01 Path-Delimiter PIC X(1).
178
+
179
+ 01 Prog-Folder PIC X(256).
180
+
181
+ 01 Prog-Extension PIC X(30).
182
+
183
+ 01 Prog-File-Name PIC X(40).
184
+
185
+ 01 Prog-Name PIC X(31).
186
+
187
+ 78 Selection-Char VALUE '>'.
188
+
189
+ 01 Switch-Display.
190
+ 05 SD-Switch-And-Value PIC X(19).
191
+ 05 FILLER PIC X(1).
192
+ 05 SD-Description PIC X(60).
193
+
194
+ 01 Switch-Keyword PIC X(12).
195
+ GC0410 88 Switch-Is-CONFIG VALUE '@CONFIG', '@C'.
196
+ GC0410 88 Switch-Is-DEBUG VALUE '@DEBUG', '@D'.
197
+ GC0410 88 Switch-Is-DLL VALUE '@DLL'.
198
+ GC0410 88 Switch-Is-EXECUTE VALUE '@EXECUTE', '@E'.
199
+ GC0410 88 Switch-Is-EXTRA VALUE '@EXTRA', '@EX'.
200
+ GC0410 88 Switch-Is-NOTRUNC VALUE '@NOTRUNC', '@N'.
201
+ GC0410 88 Switch-Is-TRACE VALUE '@TRACE', '@T'.
202
+ GC0410 88 Switch-Is-SOURCE VALUE '@SOURCE', '@S'.
203
+ GC0410 88 Switch-Is-XREF VALUE '@XREF', '@X'.
204
+
205
+ 01 Switch-Keyword-And-Value PIC X(256).
206
+
207
+ 01 Switch-Value.
208
+ 05 SV-1 PIC X(1).
209
+ 05 FILLER PIC X(255).
210
+ 01 Switch-Value-Alt REDEFINES Switch-Value
211
+ PIC X(256).
212
+ 88 Valid-Config-Filename
213
+ VALUE 'BS2000', 'COBOL85', 'COBOL2002', 'DEFAULT',
214
+ 'IBM', 'MF', 'MVS'.
215
+
216
+ 01 Switches.
217
+ 05 S-ARGS PIC X(75) VALUE SPACES.
218
+ 05 S-CfgS.
219
+ 10 S-Cfg-BS2000 PIC X(1) VALUE ' '.
220
+ 10 S-Cfg-COBOL85 PIC X(1) VALUE ' '.
221
+ 10 S-Cfg-COBOL2002 PIC X(1) VALUE ' '.
222
+ 10 S-Cfg-DEFAULT PIC X(1) VALUE Selection-Char.
223
+ 10 S-Cfg-IBM PIC X(1) VALUE ' '.
224
+ 10 S-Cfg-MF PIC X(1) VALUE ' '.
225
+ 10 S-Cfg-MVS PIC X(1) VALUE ' '.
226
+ 05 S-EXTRA PIC X(75) VALUE SPACES.
227
+ 05 S-Yes-No-Switches.
228
+ 10 S-DEBUG PIC X(1) VALUE 'N'.
229
+ 10 S-DLL PIC X(1) VALUE 'N'.
230
+ GC0410 10 S-XREF PIC X(1) VALUE 'N'.
231
+ GC0410 10 S-SOURCE PIC X(1) VALUE 'N'.
232
+ 10 S-EXECUTE PIC X(1) VALUE 'N'.
233
+ 10 S-NOTRUNC PIC X(1) VALUE 'Y'.
234
+ 10 S-SUBROUTINE PIC X(1) VALUE 'A'.
235
+ 10 S-TRACE PIC X(1) VALUE 'N'.
236
+ 10 S-TRACEALL PIC X(1) VALUE 'N'.
237
+
238
+ 01 Tally USAGE BINARY-LONG.
239
+
240
+ SCREEN SECTION.
241
+ *>
242
+ *> Here is the layout of the OCic screen.
243
+ *>
244
+ *> Note that this program can utilize the traditional PC line-drawing characters,
245
+ *> if they are available.
246
+ *>
247
+ *> If this program is run on Windows, it must run with codepage 437 activated to
248
+ *> display the line-drawing characters. With a native Windows build or a
249
+ *> Windows/MinGW build, one could use the command "chcp 437" to set that codepage
250
+ *> for display within a Windows console window (that should be the default, though).
251
+ *> With a Windows/Cygwin build, set the environment variable CYGWIN to a value of
252
+ *> "codepage:oem" (this cannot be done from within the program though - you will
253
+ *> have to use the "Computer/Advanced System Settings/Environment Variables" (Vista or
254
+ *> Windows 7) function to define the variable. XP Users: use "My Computer/Properties/
255
+ *> Advanced/Environment Variables".
256
+ *>
257
+ *> To use OCic without the line-drawing characters, comment-out the first set of
258
+ *> 78 "LD" items and uncomment the second.
259
+ *>
260
+ *> The following sample screen layout shows how the screen looks with line-drawing
261
+ *> characters disabled.
262
+ *>
263
+ *>===================================================================================
264
+ *> OCic (2010/04/02 11:36) - OpenCOBOL V1.1 Interactive Compilation Windows 01
265
+ *> +-----------------------------------------------------------------------------+ 02
266
+ *> | Program: OCic F-Key: Select Opt | 03
267
+ *> | Folder: E:\OpenCOBOL\Samples Enter: Compile | 04
268
+ *> | Filename: OCic.cbl Esc: Quit | 05
269
+ *> +-----------------------------------------------------------------------------+ 06
270
+ *> On/Off Switches: Configuration: 07
271
+ *> +---------------------------------------------------------+-------------------+ 08
272
+ *> | F1 Compile debug lines F8 Produce source listing | S-F1 BS2000 | 09
273
+ *> | F2 Always make DLLs F9 Produce xref listing | S-F2 COBOL85 | 10
274
+ *> | F3 Pgm is a SUBROUTINE | S-F3 COBOL2002 | 11
275
+ *> | F4 Execute if compile OK | S-F4 > Default | 12
276
+ *> | F5 > No COMP/BINARY trunc | S-F5 IBM | 13
277
+ *> | F6 Trace procedures | S-F6 MicroFocus | 14
278
+ *> | F7 Trace proc + stmnts | S-F7 MVS | 15
279
+ *> +---------------------------------------------------------+-------------------+ 16
280
+ *> Additional "cobc" Switches (if any): 17
281
+ *> +-----------------------------------------------------------------------------+ 18
282
+ *> | -O2________________________________________________________________________ | 19
283
+ *> +-----------------------------------------------------------------------------+ 20
284
+ *> Program Execution Arguments (if any): 21
285
+ *> +-----------------------------------------------------------------------------+ 22
286
+ *> | ___________________________________________________________________________ | 23
287
+ *> +-----------------------------------------------------------------------------+ 24
288
+ *> OCic Copyright (C) 2009-2010, Gary L. Cutler, GPL 25
289
+ *>===================================================================================
290
+ *>12345678901234567890123456789012345678901234567890123456789012345678901234567890
291
+ *> 1 2 3 4 5 6 7 8
292
+ *>
293
+ *> USE THESE CHARS FOR LINE-DRAWING IF YOU HAVE ACCESS TO PC-DOS CODEPAGE 437:
294
+ *>
295
+ 78 LD-UL-Corner VALUE X"DA".
296
+ 78 LD-LL-Corner VALUE X"C0".
297
+ 78 LD-UR-Corner VALUE X"BF".
298
+ 78 LD-LR-Corner VALUE X"D9".
299
+ 78 LD-Upper-T VALUE X"C2".
300
+ 78 LD-Lower-T VALUE X"C1".
301
+ 78 LD-Horiz-Line VALUE X"C4".
302
+ 78 LD-Vert-Line VALUE X"B3".
303
+ *>
304
+ *> USE THESE CHARS FOR LINE-DRAWING IF YOU DO NOT HAVE ACCESS TO PC-DOS CODEPAGE 437:
305
+ *>
306
+ *> 78 LD-UL-Corner VALUE '+'.
307
+ *> 78 LD-LL-Corner VALUE '+'.
308
+ *> 78 LD-UR-Corner VALUE '+'.
309
+ *> 78 LD-LR-Corner VALUE '+'.
310
+ *> 78 LD-Upper-T VALUE '+'.
311
+ *> 78 LD-Lower-T VALUE '+'.
312
+ *> 78 LD-Horiz-Line VALUE '-'.
313
+ *> 78 LD-Vert-Line VALUE '|'.
314
+ *>
315
+ 01 Blank-Screen LINE 1 COLUMN 1 BLANK SCREEN.
316
+
317
+ 01 Switches-Screen BACKGROUND-COLOR COB-COLOR-BLACK
318
+ FOREGROUND-COLOR COB-COLOR-WHITE AUTO.
319
+ *>
320
+ *> GENERAL SCREEN FRAMEWORK
321
+ *>
322
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
323
+ FOREGROUND-COLOR COB-COLOR-BLUE HIGHLIGHT.
324
+ 05 LINE 02 COL 02 VALUE LD-UL-Corner.
325
+ 05 PIC X(77) FROM Horizontal-Line.
326
+ 05 COL 80 VALUE LD-UR-Corner.
327
+
328
+ 05 LINE 03 COL 02 VALUE LD-Vert-Line.
329
+ 05 COL 80 VALUE LD-Vert-Line.
330
+
331
+ 05 LINE 04 COL 02 VALUE LD-Vert-Line.
332
+ 05 COL 80 VALUE LD-Vert-Line.
333
+
334
+ 05 LINE 05 COL 02 VALUE LD-Vert-Line.
335
+ 05 COL 80 VALUE LD-Vert-Line.
336
+
337
+ 05 LINE 06 COL 02 VALUE LD-LL-Corner.
338
+ 05 PIC X(77) FROM Horizontal-Line.
339
+ 05 COL 80 VALUE LD-LR-Corner.
340
+
341
+ 05 LINE 08 COL 02 VALUE LD-UL-Corner.
342
+ 05 PIC X(57) FROM Horizontal-Line.
343
+ 05 COL 60 VALUE LD-Upper-T.
344
+ 05 PIC X(19) FROM Horizontal-Line.
345
+ 05 COL 80 VALUE LD-UR-Corner.
346
+
347
+ 05 LINE 09 COL 02 VALUE LD-Vert-Line.
348
+ 05 COL 60 VALUE LD-Vert-Line.
349
+ 05 COL 80 VALUE LD-Vert-Line.
350
+
351
+ 05 LINE 10 COL 02 VALUE LD-Vert-Line.
352
+ 05 COL 60 VALUE LD-Vert-Line.
353
+ 05 COL 80 VALUE LD-Vert-Line.
354
+
355
+ 05 LINE 11 COL 02 VALUE LD-Vert-Line.
356
+ 05 COL 60 VALUE LD-Vert-Line.
357
+ 05 COL 80 VALUE LD-Vert-Line.
358
+
359
+ 05 LINE 12 COL 02 VALUE LD-Vert-Line.
360
+ 05 COL 60 VALUE LD-Vert-Line.
361
+ 05 COL 80 VALUE LD-Vert-Line.
362
+
363
+ 05 LINE 13 COL 02 VALUE LD-Vert-Line.
364
+ 05 COL 60 VALUE LD-Vert-Line.
365
+ 05 COL 80 VALUE LD-Vert-Line.
366
+
367
+ 05 LINE 14 COL 02 VALUE LD-Vert-Line.
368
+ 05 COL 60 VALUE LD-Vert-Line.
369
+ 05 COL 80 VALUE LD-Vert-Line.
370
+
371
+ 05 LINE 15 COL 02 VALUE LD-Vert-Line.
372
+ 05 COL 60 VALUE LD-Vert-Line.
373
+ 05 COL 80 VALUE LD-Vert-Line.
374
+
375
+ 05 LINE 16 COL 02 VALUE LD-LL-Corner.
376
+ 05 PIC X(57) FROM Horizontal-Line.
377
+ 05 COL 60 VALUE LD-Lower-T.
378
+ 05 PIC X(19) FROM Horizontal-Line.
379
+ 05 COL 80 VALUE LD-LR-Corner.
380
+
381
+ 05 LINE 18 COL 02 VALUE LD-UL-Corner.
382
+ 05 PIC X(77) FROM Horizontal-Line.
383
+ 05 COL 80 VALUE LD-UR-Corner.
384
+
385
+ 05 LINE 19 COL 02 VALUE LD-Vert-Line.
386
+ 05 COL 80 VALUE LD-Vert-Line.
387
+
388
+ 05 LINE 20 COL 02 VALUE LD-LL-Corner.
389
+ 05 PIC X(77) FROM Horizontal-Line.
390
+ 05 COL 80 VALUE LD-LR-Corner.
391
+
392
+ 05 LINE 22 COL 02 VALUE LD-UL-Corner.
393
+ 05 PIC X(77) FROM Horizontal-Line.
394
+ 05 COL 80 VALUE LD-UR-Corner.
395
+
396
+ 05 LINE 23 COL 02 VALUE LD-Vert-Line.
397
+ 05 COL 80 VALUE LD-Vert-Line.
398
+
399
+ 05 LINE 24 COL 02 VALUE LD-LL-Corner.
400
+ 05 PIC X(77) FROM Horizontal-Line.
401
+ 05 COL 80 VALUE LD-LR-Corner.
402
+ *>
403
+ *> TOP AND BOTTOM LINES
404
+ *>
405
+ 03 BACKGROUND-COLOR COB-COLOR-BLUE BLINK
406
+ FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
407
+ GC0410 05 LINE 01 COL 01 VALUE ' OCic ('.
408
+ GC0410 05 PIC X(16) FROM OC-Compiled.
409
+ GC0410 05 VALUE ') OpenCOBOL V1.1 06FEB2009 ' &
410
+ GC0410 'Interactive Compilation '.
411
+ GC0410 05 LINE 25 COL 01 PIC X(81) FROM Output-Message.
412
+ *>
413
+ *> LABELS
414
+ *>
415
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
416
+ FOREGROUND-COLOR COB-COLOR-CYAN HIGHLIGHT.
417
+ 05 LINE 07 COL 04 VALUE 'On/Off Switches:'.
418
+ 05 COL 62 VALUE 'Configuration:'.
419
+ 05 LINE 17 COL 04 VALUE 'Additional "cobc" Switches (if any
420
+ - '):'.
421
+ 05 LINE 21 COL 04 VALUE 'Program Execution Arguments (if an
422
+ - 'y):'.
423
+ *>
424
+ *> TOP SECTION BACKGROUND
425
+ *>
426
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
427
+ FOREGROUND-COLOR COB-COLOR-CYAN LOWLIGHT.
428
+ 05 LINE 03 COL 04 VALUE 'Program: '.
429
+ 05 LINE 04 COL 04 VALUE 'Folder: '.
430
+ 05 LINE 05 COL 04 VALUE 'Filename: '.
431
+
432
+ 05 LINE 03 COL 62 VALUE 'F-Key: Select Opt'.
433
+ 05 LINE 04 COL 62 VALUE 'Enter: Compile '.
434
+ 05 LINE 05 COL 62 VALUE 'Esc: Quit '.
435
+ *>
436
+ *> TOP SECTION PROGRAM INFO
437
+ *>
438
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
439
+ FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
440
+ 05 LINE 03 COL 14 PIC X(47) FROM Prog-Name.
441
+ 05 LINE 04 COL 14 PIC X(47) FROM Prog-Folder.
442
+ 05 LINE 05 COL 14 PIC X(47) FROM Prog-File-Name.
443
+ *>
444
+ *> MIDDLE LEFT SECTION F-KEYS
445
+ *>
446
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
447
+ FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
448
+ 05 LINE 09 COL 04 VALUE 'F1'.
449
+ 05 LINE 10 COL 04 VALUE 'F2'.
450
+ 05 LINE 11 COL 04 VALUE 'F3'.
451
+ 05 LINE 12 COL 04 VALUE 'F4'.
452
+ 05 LINE 13 COL 04 VALUE 'F5'.
453
+ 05 LINE 14 COL 04 VALUE 'F6'.
454
+ 05 LINE 15 COL 04 VALUE 'F7'.
455
+ 05 LINE 09 COL 32 VALUE 'F8'.
456
+ 05 LINE 10 COL 32 VALUE 'F9'.
457
+ *>
458
+ *> MIDDLE LEFT SECTION SWITCHES
459
+ *>
460
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
461
+ FOREGROUND-COLOR COB-COLOR-RED HIGHLIGHT.
462
+ 05 LINE 09 COL 07 PIC X(1) FROM S-DEBUG.
463
+ 05 LINE 10 COL 07 PIC X(1) FROM S-DLL.
464
+ 05 LINE 11 COL 07 PIC X(1) FROM S-SUBROUTINE.
465
+ 05 LINE 12 COL 07 PIC X(1) FROM S-EXECUTE.
466
+ 05 LINE 13 COL 07 PIC X(1) FROM S-NOTRUNC.
467
+ 05 LINE 14 COL 07 PIC X(1) FROM S-TRACE.
468
+ 05 LINE 15 COL 07 PIC X(1) FROM S-TRACEALL.
469
+ 05 LINE 09 COL 35 PIC X(1) FROM S-SOURCE.
470
+ 05 LINE 10 COL 35 PIC X(1) FROM S-XREF.
471
+ *>
472
+ *> MIDDLE LEFT SECTION BACKGROUND
473
+ *>
474
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
475
+ FOREGROUND-COLOR COB-COLOR-CYAN LOWLIGHT.
476
+ 05 LINE 09 COL 09 VALUE 'Compile debug lines '.
477
+ 05 LINE 10 COL 09 VALUE 'Always make DLLs '.
478
+ 05 LINE 11 COL 09 VALUE 'Pgm is a SUBROUTINE '.
479
+ 05 LINE 12 COL 09 VALUE 'Execute if compile OK '.
480
+ 05 LINE 13 COL 09 VALUE 'No COMP/BINARY trunc '.
481
+ 05 LINE 14 COL 09 VALUE 'Trace procedures '.
482
+ 05 LINE 15 COL 09 VALUE 'Trace proc + stmnts '.
483
+ 05 LINE 09 COL 37 VALUE 'Produce source listing'.
484
+ 05 LINE 10 COL 37 VALUE 'Produce xref listing '.
485
+ *>
486
+ *> MIDDLE RIGHT SECTION F-KEYS
487
+ *>
488
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
489
+ FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
490
+ 05 LINE 09 COL 62 VALUE 'S-F1'.
491
+ 05 LINE 10 COL 62 VALUE 'S-F2'.
492
+ 05 LINE 11 COL 62 VALUE 'S-F3'.
493
+ 05 LINE 12 COL 62 VALUE 'S-F4'.
494
+ 05 LINE 13 COL 62 VALUE 'S-F5'.
495
+ 05 LINE 14 COL 62 VALUE 'S-F6'.
496
+ 05 LINE 15 COL 62 VALUE 'S-F7'.
497
+ *>
498
+ *> MIDDLE RIGHT SECTION SWITCHES
499
+ *>
500
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
501
+ FOREGROUND-COLOR COB-COLOR-RED HIGHLIGHT.
502
+ 05 LINE 09 COL 67 PIC X(1) FROM S-Cfg-BS2000.
503
+ 05 LINE 10 COL 67 PIC X(1) FROM S-Cfg-COBOL85.
504
+ 05 LINE 11 COL 67 PIC X(1) FROM S-Cfg-COBOL2002.
505
+ 05 LINE 12 COL 67 PIC X(1) FROM S-Cfg-DEFAULT.
506
+ 05 LINE 13 COL 67 PIC X(1) FROM S-Cfg-IBM.
507
+ 05 LINE 14 COL 67 PIC X(1) FROM S-Cfg-MF.
508
+ 05 LINE 15 COL 67 PIC X(1) FROM S-Cfg-MVS.
509
+ *>
510
+ *> MIDDLE RIGHT SECTION BACKGROUND
511
+ *>
512
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
513
+ FOREGROUND-COLOR COB-COLOR-CYAN LOWLIGHT.
514
+ 05 LINE 09 COL 69 VALUE 'BS2000 '.
515
+ 05 LINE 10 COL 69 VALUE 'COBOL85 '.
516
+ 05 LINE 11 COL 69 VALUE 'COBOL2002 '.
517
+ 05 LINE 12 COL 69 VALUE 'Default '.
518
+ 05 LINE 13 COL 69 VALUE 'IBM '.
519
+ 05 LINE 14 COL 69 VALUE 'MicroFocus'.
520
+ 05 LINE 15 COL 69 VALUE 'MVS '.
521
+ *>
522
+ *> FREE-FORM OPTIONS FIELDS
523
+ *>
524
+ 03 BACKGROUND-COLOR COB-COLOR-BLACK
525
+ FOREGROUND-COLOR COB-COLOR-WHITE HIGHLIGHT.
526
+ 05 LINE 19 COL 04 PIC X(75) USING S-EXTRA.
527
+ 05 LINE 23 COL 04 PIC X(75) USING S-ARGS.
528
+ /
529
+ PROCEDURE DIVISION.
530
+ *****************************************************************
531
+ ** Legend to procedure names: **
532
+ ** **
533
+ ** 00x-xxx All MAIN driver procedures **
534
+ ** 0xx-xxx All GLOBAL UTILITY procedures **
535
+ ** 1xx-xxx All INITIALIZATION procedures **
536
+ ** 2xx-xxx All CORE PROCESSING procedures **
537
+ ** 9xx-xxx All TERMINATION procedures **
538
+ *****************************************************************
539
+ DECLARATIVES.
540
+ 000-File-Error SECTION.
541
+ USE AFTER STANDARD ERROR PROCEDURE ON Source-Code.
542
+ 000-Handle-Error.
543
+ COPY FileStat-Msgs
544
+ REPLACING STATUS BY FSM-Status
545
+ MSG BY FSM-Msg.
546
+ MOVE SPACES TO Output-Message
547
+ IF FSM-Status = 35
548
+ DISPLAY
549
+ 'File not found: "'
550
+ TRIM(File-Name,TRAILING)
551
+ '"'
552
+ END-DISPLAY
553
+ ELSE
554
+ DISPLAY
555
+ 'Error accessing file: "'
556
+ TRIM(File-Name,TRAILING)
557
+ '"'
558
+ END-DISPLAY
559
+ END-IF
560
+ GOBACK
561
+ .
562
+ END DECLARATIVES.
563
+ /
564
+ 000-Main SECTION.
565
+
566
+ PERFORM 100-Initialization
567
+ GC0609 SET 88-Not-Complete TO TRUE
568
+ GC0609 PERFORM UNTIL 88-Complete
569
+ GC0609 PERFORM 200-Let-User-Set-Switches
570
+ GC0609 PERFORM 210-Run-Compiler
571
+ GC0410 IF (88-Compile-OK OR 88-Compile-OK-Warn)
572
+ GC0410 AND (S-XREF NOT = SPACE OR S-SOURCE NOT = SPACE)
573
+ GC0410 PERFORM 220-Make-Listing
574
+ GC0410 END-IF
575
+ GC0709 IF (S-EXECUTE NOT = SPACES)
576
+ GC0709 AND (88-Output-File-Avail)
577
+ GC0609 PERFORM 230-Run-Program
578
+ GC0609 END-IF
579
+ GC0609 END-PERFORM
580
+ .
581
+
582
+ 009-Done.
583
+ PERFORM 900-Terminate
584
+ .
585
+ * -- Control will NOT return
586
+ /
587
+ 010-Parse-Args SECTION.
588
+ *****************************************************************
589
+ ** Process a sequence of KEYWORD=VALUE items. These are items **
590
+ ** specified on the command-line to provide the initial **
591
+ ** options shown selected on the screen. When integrating **
592
+ ** OCic into an edirot or framework, include these switches on **
593
+ ** the ocic.exe command the editor/framework executes. Any **
594
+ ** underlined choice is the default value for that switch. **
595
+ ** **
596
+ ** @CONFIG=BS2000|COBOL85|COBOL2002|DEFAULT|IBM|MF|MVS **
597
+ ** ======= **
598
+ ** This switch specifies the default cobc compiler configura- **
599
+ ** tion file to be used **
600
+ ** **
601
+ ** @DEBUG=YES|NO **
602
+ ** == **
603
+ ** This switch specifies whether (YES) or not (NO) debugging **
604
+ ** lines (those with a "D" in column 7) will be compiled. **
605
+ ** **
606
+ ** @DLL=YES|NO **
607
+ ** == **
608
+ ** Use this switch to force ALL compiled programs to be built **
609
+ ** as DLLs ("@DLL=YES"). When main programs are built as DLLs **
610
+ ** they must be executed using the cobcrun utility. When **
611
+ ** "@DLL=NO" is in effect, main programs are generated as **
612
+ ** actual "exe" files and only subprograms will be generated **
613
+ ** as DLLs. **
614
+ ** **
615
+ ** @EXECUTE=YES|NO **
616
+ ** == **
617
+ ** This switch specifies whether ("@EXECUTE=YES") or not **
618
+ ** ("@EXECUTE=NO") the program will be executed after it is **
619
+ ** successfully compiled. **
620
+ ** **
621
+ ** @EXTRA=extra cobc argument(s) **
622
+ ** **
623
+ ** This switch allows you to specify additional cobc arguments **
624
+ ** that aren't managed by the other OC switches. If used, **
625
+ ** this must be the last switch specified on the command line, **
626
+ ** as everything that follows the "=" will be placed on the **
627
+ ** cobc command generated by OC. **
628
+ ** **
629
+ ** @NOTRUNC=YES|NO **
630
+ ** === **
631
+ ** This switch specifies whether (YES) or not (NO) the sup- **
632
+ ** pression of binary field truncation will occur. If a PIC **
633
+ ** 99 COMP field (one byte of storage), for example, is given **
634
+ ** the value 123, it may have its value truncated to 23 when **
635
+ ** DISPLAYed. Regardless of the NOTRUNC setting, internally **
636
+ ** the full precision of the field (allowing a maximum value **
637
+ ** of 255) will be preserved. Even though truncation - if it **
638
+ ** does occur - would appear to have a minimal disruption on **
639
+ ** program operation, it has a significant effect on program **
640
+ ** run-time speed. **
641
+ ** **
642
+ ** @TRACE=YES|NO|ALL **
643
+ ** == **
644
+ ** This switch controls whether or not code will be added to **
645
+ ** the object program to produce execution-time logic traces. **
646
+ ** A specification of "@TRACE=NO" means no such code will be **
647
+ ** produced. By specifying "@TRACE=YES", code will be genera- **
648
+ ** ted to display procedure names as they are entered. A **
649
+ ** "@TRACE=ALL" specification will generate not only procedure **
650
+ ** traces (as "@TRACE=YES" would) but also statement-level **
651
+ ** traces too! All trace output is written to STDERR, so **
652
+ ** adding a "2>file" to the execution of the program will pipe **
653
+ ** the trace output to a file. You may find it valuable to **
654
+ ** add your own DISPLAY statements to the debugging output via **
655
+ ** "DISPLAY xx UPON SYSERR" The SYSERR device corresponds to **
656
+ ** the Windows or UNIX STDERR device and will therefore honor **
657
+ ** any "2>file" placed at the end of your program's execution. **
658
+ ** Add a "D" in column 7 and you can control the generation or **
659
+ ** ignoring of these DISPLAY statements via the "@DEBUG" **
660
+ ** switch. **
661
+ ** **
662
+ GC0410** @SOURCE=YES|NO **
663
+ GC0410** == **
664
+ GC0410** Use this switch to produce a source listing of the program, **
665
+ GC0410** PROVIDED it compiles without errors. **
666
+ ** **
667
+ GC0410** @XREF=YES|NO **
668
+ GC0410** == **
669
+ GC0410** Use this switch to produce a cross-reference listing of the **
670
+ GC0410** program, PROVIDED it compiles without errors. **
671
+ *****************************************************************
672
+
673
+ 011-Init.
674
+ MOVE 1 TO I
675
+ .
676
+
677
+ 012-Extract-Kwd-And-Value.
678
+ PERFORM UNTIL I NOT < LENGTH(Command-Line-Args)
679
+ MOVE I TO J
680
+ UNSTRING Command-Line-Args
681
+ DELIMITED BY ALL SPACES
682
+ INTO Switch-Keyword-And-Value
683
+ WITH POINTER I
684
+ END-UNSTRING
685
+ IF Switch-Keyword-And-Value NOT = SPACES
686
+ UNSTRING Switch-Keyword-And-Value
687
+ DELIMITED BY '='
688
+ INTO Switch-Keyword, Switch-Value
689
+ END-UNSTRING
690
+ PERFORM 030-Process-Keyword
691
+ END-IF
692
+ END-PERFORM
693
+ .
694
+
695
+ 019-Done.
696
+ EXIT.
697
+
698
+ *****************************************************************
699
+ ** Since this program uses the SCREEN SECTION, it cannot do **
700
+ ** conventional console DISPLAY operations. This routine **
701
+ ** (which, I admit, is like using an H-bomb to hunt rabbits) **
702
+ ** will submit an "ECHO" command to the system to simulate a **
703
+ ** DISPLAY. **
704
+ *****************************************************************
705
+ 021-Build-And-Issue-Command.
706
+ DISPLAY
707
+ Output-Message
708
+ END-DISPLAY
709
+ .
710
+
711
+ 029-Done.
712
+ EXIT.
713
+ /
714
+ 030-Process-Keyword SECTION.
715
+ *****************************************************************
716
+ ** Process a single KEYWORD=VALUE item. **
717
+ *****************************************************************
718
+
719
+ 031-Init.
720
+ MOVE UPPER-CASE(Switch-Keyword) TO Switch-Keyword
721
+ SET 88-Switch-Is-Good TO TRUE
722
+ .
723
+
724
+ 032-Process.
725
+ EVALUATE TRUE
726
+ WHEN Switch-Is-EXTRA
727
+ GC0410 MOVE J TO I
728
+ UNSTRING Command-Line-Args DELIMITED BY '='
729
+ INTO Dummy, S-EXTRA
730
+ GC0410 WITH POINTER I
731
+ GC0410 END-UNSTRING
732
+ MOVE LENGTH(Command-Line-Args) TO I
733
+ WHEN Switch-Is-CONFIG
734
+ MOVE 'CONFIG' TO Switch-Keyword
735
+ MOVE UPPER-CASE(Switch-Value)
736
+ TO Switch-Value
737
+ EVALUATE Switch-Value
738
+ WHEN 'BS2000'
739
+ MOVE SPACES TO S-CfgS
740
+ MOVE Selection-Char TO S-Cfg-BS2000
741
+ WHEN 'COBOL85'
742
+ MOVE SPACES TO S-CfgS
743
+ MOVE Selection-Char TO S-Cfg-COBOL85
744
+ WHEN 'COBOL2002'
745
+ MOVE SPACES TO S-CfgS
746
+ MOVE Selection-Char TO S-Cfg-COBOL2002
747
+ WHEN 'DEFAULT'
748
+ MOVE SPACES TO S-CfgS
749
+ MOVE Selection-Char TO S-Cfg-DEFAULT
750
+ WHEN 'IBM'
751
+ MOVE SPACES TO S-CfgS
752
+ MOVE Selection-Char TO S-Cfg-IBM
753
+ WHEN 'MF'
754
+ MOVE SPACES TO S-CfgS
755
+ MOVE Selection-Char TO S-Cfg-MF
756
+ WHEN 'MVS'
757
+ MOVE SPACES TO S-CfgS
758
+ MOVE Selection-Char TO S-Cfg-MVS
759
+ WHEN OTHER
760
+ MOVE 'An invalid /CONFIG switch value ' &
761
+ 'was specified on the command line ' &
762
+ '- ignored'
763
+ TO Output-Message
764
+ END-EVALUATE
765
+ WHEN Switch-Is-DEBUG
766
+ MOVE 'DEBUG' TO Switch-Keyword
767
+ MOVE UPPER-CASE(Switch-Value)
768
+ TO Switch-Value
769
+ PERFORM 040-Process-Yes-No-Value
770
+ IF 88-Switch-Is-Good
771
+ MOVE SV-1 TO S-DEBUG
772
+ END-IF
773
+ GC0410 WHEN Switch-Is-DLL
774
+ GC0410 MOVE 'DLL' TO Switch-Keyword
775
+ GC0410 MOVE UPPER-CASE(Switch-Value)
776
+ GC0410 TO Switch-Value
777
+ GC0410 PERFORM 040-Process-Yes-No-Value
778
+ GC0410 IF 88-Switch-Is-Good
779
+ GC0410 MOVE SV-1 TO S-DLL
780
+ GC0410 END-IF
781
+ WHEN Switch-Is-EXECUTE
782
+ MOVE 'EXECUTE' TO Switch-Keyword
783
+ MOVE UPPER-CASE(Switch-Value)
784
+ TO Switch-Value
785
+ PERFORM 040-Process-Yes-No-Value
786
+ IF 88-Switch-Is-Good
787
+ MOVE SV-1 TO S-EXECUTE
788
+ END-IF
789
+ WHEN Switch-Is-NOTRUNC
790
+ MOVE 'NOTRUNC' TO Switch-Keyword
791
+ MOVE UPPER-CASE(Switch-Value)
792
+ TO Switch-Value
793
+ PERFORM 040-Process-Yes-No-Value
794
+ IF 88-Switch-Is-Good
795
+ MOVE SV-1 TO S-NOTRUNC
796
+ END-IF
797
+ GC0410 WHEN Switch-Is-SOURCE
798
+ GC0410 MOVE 'SOURCE' TO Switch-Keyword
799
+ GC0410 MOVE UPPER-CASE(Switch-Value)
800
+ GC0410 TO Switch-Value
801
+ GC0410 PERFORM 050-Process-Yes-No-All
802
+ GC0410 IF 88-Switch-Is-Good
803
+ GC0410 MOVE SV-1 TO S-SOURCE
804
+ GC0410 END-IF
805
+ WHEN Switch-Is-TRACE
806
+ MOVE 'TRACE' TO Switch-Keyword
807
+ MOVE UPPER-CASE(Switch-Value)
808
+ TO Switch-Value
809
+ PERFORM 050-Process-Yes-No-All
810
+ IF 88-Switch-Is-Good
811
+ MOVE SV-1 TO S-TRACE
812
+ END-IF
813
+ GC0410 WHEN Switch-Is-XREF
814
+ GC0410 MOVE 'XREF' TO Switch-Keyword
815
+ GC0410 MOVE UPPER-CASE(Switch-Value)
816
+ GC0410 TO Switch-Value
817
+ GC0410 PERFORM 050-Process-Yes-No-All
818
+ GC0410 IF 88-Switch-Is-Good
819
+ GC0410 MOVE SV-1 TO S-XREF
820
+ GC0410 END-IF
821
+ WHEN OTHER
822
+ MOVE SPACES TO Output-Message
823
+ STRING '"'
824
+ TRIM(Switch-Keyword)
825
+ '" is not a valid switch ' &
826
+ '- ignored'
827
+ DELIMITED SIZE
828
+ INTO Output-Message
829
+ END-STRING
830
+ SET 88-Switch-Is-Bad TO TRUE
831
+ END-EVALUATE
832
+ .
833
+
834
+ 039-Done.
835
+ EXIT.
836
+ /
837
+ 040-Process-Yes-No-Value SECTION.
838
+ *****************************************************************
839
+ ** Process a switch value of YES or NO **
840
+ *****************************************************************
841
+
842
+ 042-Process.
843
+ EVALUATE SV-1
844
+ WHEN 'Y'
845
+ MOVE 'YES' TO Switch-Value
846
+ WHEN 'N'
847
+ MOVE 'NO' To Switch-Value
848
+ WHEN OTHER
849
+ MOVE SPACES TO Output-Message
850
+ STRING '*ERROR: "' TRIM(Switch-Value)
851
+ '" is not a valid value for the "'
852
+ TRIM(Switch-Keyword) '" switch'
853
+ DELIMITED SPACES
854
+ INTO Output-Message
855
+ END-STRING
856
+ SET 88-Switch-Is-Bad TO TRUE
857
+ END-EVALUATE
858
+ .
859
+
860
+ 049-Done.
861
+ EXIT.
862
+ /
863
+ 050-Process-Yes-No-All SECTION.
864
+ *****************************************************************
865
+ ** Process a switch value of YES, NO or ALL **
866
+ *****************************************************************
867
+
868
+ 052-Process.
869
+ IF SV-1 = 'A'
870
+ MOVE 'ALL' TO Switch-Value
871
+ ELSE
872
+ PERFORM 040-Process-Yes-No-Value
873
+ END-IF
874
+ .
875
+
876
+ 059-Done.
877
+ EXIT.
878
+ /
879
+ 060-Process-Yes-No-Auto SECTION.
880
+ *****************************************************************
881
+ ** Process a switch value of YES, NO or AUTO **
882
+ *****************************************************************
883
+
884
+ 061-Init.
885
+ IF SV-1 = 'A'
886
+ PERFORM 070-Find-LINKAGE-SECTION
887
+ IF 88-Compile-As-Subpgm
888
+ MOVE 'Y' TO Switch-Value
889
+ ELSE
890
+ MOVE 'N' TO Switch-Value
891
+ END-IF
892
+ ELSE
893
+ PERFORM 040-Process-Yes-No-Value
894
+ END-IF
895
+ .
896
+ /
897
+ 070-Find-LINKAGE-SECTION SECTION.
898
+ *****************************************************************
899
+ ** Determine if the program being compiled is a MAIN program **
900
+ *****************************************************************
901
+
902
+ 071-Init.
903
+ OPEN INPUT Source-Code
904
+ SET 88-Compile-As-Mainpgm TO TRUE
905
+ SET 88-More-To-1st-Prog TO TRUE
906
+ PERFORM UNTIL 88-1st-Prog-Complete
907
+ READ Source-Code AT END
908
+ CLOSE Source-Code
909
+ EXIT SECTION
910
+ END-READ
911
+ CALL 'CHECKSOURCE' USING Source-Code-Record
912
+ F-Source-Record-Type
913
+ END-CALL
914
+ IF 88-Source-Rec-Ident
915
+ SET 88-1st-Prog-Complete TO TRUE
916
+ END-IF
917
+ END-PERFORM
918
+ .
919
+
920
+ 072-Process-Source.
921
+ SET 88-Source-Rec-IgnoCOB-COLOR-RED TO TRUE
922
+ PERFORM UNTIL 88-Source-Rec-Linkage
923
+ OR 88-Source-Rec-Ident
924
+ READ Source-Code AT END
925
+ CLOSE Source-Code
926
+ EXIT SECTION
927
+ END-READ
928
+ CALL 'CHECKSOURCE' USING Source-Code-Record
929
+ F-Source-Record-Type
930
+ END-CALL
931
+ END-PERFORM
932
+ CLOSE Source-Code
933
+ IF 88-Source-Rec-Linkage
934
+ SET 88-Compile-As-Subpgm TO TRUE
935
+ END-IF
936
+ .
937
+
938
+ 079-Done.
939
+ EXIT.
940
+ /
941
+ 100-Initialization SECTION.
942
+ *****************************************************************
943
+ ** Perform all program-wide initialization operations **
944
+ *****************************************************************
945
+
946
+
947
+ GC0909 101-Determine-OS-Type.
948
+ GC0909 CALL 'GETOSTYPE'
949
+ GC0909 END-CALL
950
+ GC0909 MOVE RETURN-CODE TO OS-Type
951
+ GC0909 EVALUATE TRUE
952
+ GC0909 WHEN OS-Unknown
953
+ GC0909 MOVE '\' TO Dir-Char
954
+ GC0909 MOVE 'Unknown' TO OS-Type-Literal
955
+ GC0310 MOVE COB-SCR-F11 TO CK-S-F1
956
+ GC0310 MOVE COB-SCR-F12 TO CK-S-F2
957
+ GC0310 MOVE COB-SCR-F13 TO CK-S-F3
958
+ GC0310 MOVE COB-SCR-F14 TO CK-S-F4
959
+ GC0310 MOVE COB-SCR-F15 TO CK-S-F5
960
+ GC0310 MOVE COB-SCR-F16 TO CK-S-F6
961
+ GC0310 MOVE COB-SCR-F17 TO CK-S-F7
962
+ GC0909 WHEN OS-Windows
963
+ GC0909 MOVE '\' TO Dir-Char
964
+ GC0909 MOVE 'Windows' TO OS-Type-Literal
965
+ GC0310 MOVE COB-SCR-F13 TO CK-S-F1
966
+ GC0310 MOVE COB-SCR-F14 TO CK-S-F2
967
+ GC0310 MOVE COB-SCR-F15 TO CK-S-F3
968
+ GC0310 MOVE COB-SCR-F16 TO CK-S-F4
969
+ GC0310 MOVE COB-SCR-F17 TO CK-S-F5
970
+ GC0310 MOVE COB-SCR-F18 TO CK-S-F6
971
+ GC0310 MOVE COB-SCR-F19 TO CK-S-F7
972
+ GC0909 WHEN OS-Cygwin
973
+ GC0909 MOVE '/' TO Dir-Char
974
+ GC0410 MOVE 'Cygwin' TO OS-Type-Literal
975
+ GC0310 MOVE COB-SCR-F11 TO CK-S-F1
976
+ GC0310 MOVE COB-SCR-F12 TO CK-S-F2
977
+ GC0310 MOVE COB-SCR-F13 TO CK-S-F3
978
+ GC0310 MOVE COB-SCR-F14 TO CK-S-F4
979
+ GC0310 MOVE COB-SCR-F15 TO CK-S-F5
980
+ GC0310 MOVE COB-SCR-F16 TO CK-S-F6
981
+ GC0310 MOVE COB-SCR-F17 TO CK-S-F7
982
+ GC0909 WHEN OS-UNIX
983
+ GC0909 MOVE '/' TO Dir-Char
984
+ GC0410 MOVE 'UNIX ' TO OS-Type-Literal
985
+ GC0310 MOVE COB-SCR-F11 TO CK-S-F1
986
+ GC0310 MOVE COB-SCR-F12 TO CK-S-F2
987
+ GC0310 MOVE COB-SCR-F13 TO CK-S-F3
988
+ GC0310 MOVE COB-SCR-F14 TO CK-S-F4
989
+ GC0310 MOVE COB-SCR-F15 TO CK-S-F5
990
+ GC0310 MOVE COB-SCR-F16 TO CK-S-F6
991
+ GC0310 MOVE COB-SCR-F17 TO CK-S-F7
992
+ GC0909 END-EVALUATE
993
+ GC0909 .
994
+
995
+ 102-Set-Environment-Vars.
996
+ SET ENVIRONMENT 'COB_SCREEN_EXCEPTIONS' TO 'Y'
997
+ SET ENVIRONMENT 'COB_SCREEN_ESC' TO 'Y'
998
+ .
999
+
1000
+ 103-Generate-Cobc-Output-Fn.
1001
+ ACCEPT Env-TEMP
1002
+ FROM ENVIRONMENT "TEMP"
1003
+ END-ACCEPT
1004
+ MOVE SPACES TO Cobc-Output-File
1005
+ STRING TRIM(Env-TEMP,TRAILING)
1006
+ GC0909 Dir-Char
1007
+ GC0909 'OC-Messages.TXT'
1008
+ DELIMITED SIZE
1009
+ INTO Cobc-Output-File
1010
+ END-STRING
1011
+ .
1012
+
1013
+ 104-Generate-Banner-Line-Info.
1014
+ MOVE WHEN-COMPILED (1:12) TO OC-Compiled
1015
+ INSPECT OC-Compiled
1016
+ REPLACING ALL '/' BY ':'
1017
+ AFTER INITIAL SPACE
1018
+ .
1019
+
1020
+ 105-Establish-Switch-Settings.
1021
+ ACCEPT Command-Line-Args
1022
+ FROM COMMAND-LINE
1023
+ END-ACCEPT
1024
+ MOVE TRIM(Command-Line-Args, Leading)
1025
+ TO Command-Line-Args
1026
+ MOVE 0 TO Tally
1027
+ GC0410 INSPECT Command-Line-Args TALLYING Tally FOR ALL '@'
1028
+ IF Tally = 0
1029
+ MOVE Command-Line-Args TO File-Name
1030
+ MOVE SPACES TO Command-Line-Args
1031
+ ELSE
1032
+ GC0410 UNSTRING Command-Line-Args DELIMITED BY '@'
1033
+ INTO File-Name, Dummy
1034
+ END-UNSTRING
1035
+ INSPECT Command-Line-Args
1036
+ GC0410 REPLACING FIRST '@' BY LOW-VALUES
1037
+ UNSTRING Command-Line-Args
1038
+ DELIMITED BY LOW-VALUES
1039
+ INTO Dummy, Cmd
1040
+ END-UNSTRING
1041
+ MOVE SPACES TO Command-Line-Args
1042
+ GC0410 STRING '@' Cmd DELIMITED SIZE
1043
+ INTO Command-Line-Args
1044
+ END-STRING
1045
+ END-IF
1046
+ IF File-Name = SPACES
1047
+ DISPLAY
1048
+ 'No program filename was specified'
1049
+ END-DISPLAY
1050
+ PERFORM 900-Terminate
1051
+ END-IF
1052
+ PERFORM 010-Parse-Args
1053
+ IF S-SUBROUTINE = 'A'
1054
+ MOVE 'S' TO Switch-Keyword
1055
+ MOVE 'A' TO Switch-Value
1056
+ PERFORM 070-Find-LINKAGE-SECTION
1057
+ IF 88-Compile-As-Subpgm
1058
+ MOVE 'Y' TO S-SUBROUTINE
1059
+ ELSE
1060
+ MOVE 'N' TO S-SUBROUTINE
1061
+ END-IF
1062
+ END-IF
1063
+ INSPECT S-Yes-No-Switches REPLACING ALL 'Y' BY Selection-Char
1064
+ INSPECT S-Yes-No-Switches REPLACING ALL 'N' BY ' '
1065
+ .
1066
+
1067
+ 106-Determine-Folder-Path.
1068
+ Move 256 TO I
1069
+ GC0909 IF OS-Cygwin AND File-Name (2:1) = ':'
1070
+ GC0909 MOVE '\' TO Dir-Char
1071
+ GC0909 END-IF
1072
+ PERFORM UNTIL I = 0 OR FN-Char (I) = Dir-Char
1073
+ SUBTRACT 1 FROM I
1074
+ END-PERFORM
1075
+ IF I = 0
1076
+ MOVE SPACES TO Prog-Folder
1077
+ MOVE File-Name TO Prog-File-Name
1078
+ ELSE
1079
+ MOVE '*' TO FN-Char (I)
1080
+ UNSTRING File-Name DELIMITED BY '*'
1081
+ INTO Prog-Folder
1082
+ Prog-File-Name
1083
+ END-UNSTRING
1084
+ MOVE Dir-Char TO FN-Char (I)
1085
+ END-IF
1086
+ UNSTRING Prog-File-Name DELIMITED BY '.'
1087
+ INTO Prog-Name, Prog-Extension
1088
+ END-UNSTRING
1089
+ IF Prog-Folder = SPACES
1090
+ ACCEPT Prog-Folder
1091
+ FROM ENVIRONMENT 'CD'
1092
+ END-ACCEPT
1093
+ GC0909 ELSE
1094
+ GC0909 CALL "CBL_CHANGE_DIR"
1095
+ GC0909 USING TRIM(Prog-Folder,TRAILING)
1096
+ GC0909 END-CALL
1097
+ END-IF
1098
+ GC0909 IF OS-Cygwin AND File-Name (2:1) = ':'
1099
+ GC0909 MOVE '/' TO Dir-Char
1100
+ GC0909 END-IF
1101
+ .
1102
+
1103
+ GC0909 107-Other.
1104
+ GC0909 MOVE ALL LD-Horiz-Line TO Horizontal-Line.
1105
+ GC0410 MOVE CONCATENATE(' OCic for ',
1106
+ GC0410 TRIM(OS-Type-Literal,Trailing),
1107
+ GC0410 ' Copyright (C) 2009-2010, Gary L. Cutler,',
1108
+ GC0410 ' GPL')
1109
+ GC0410 TO Output-Message.
1110
+ GC0909 .
1111
+ GC0909
1112
+ 109-Done.
1113
+ EXIT.
1114
+ /
1115
+ 200-Let-User-Set-Switches SECTION.
1116
+ *****************************************************************
1117
+ ** Show the user the current switch settings and allow them to **
1118
+ ** be changed. **
1119
+ *****************************************************************
1120
+
1121
+ 201-Init.
1122
+ SET 88-Switch-Changes TO TRUE
1123
+ .
1124
+
1125
+ 202-Show-And-Change-Switches.
1126
+ PERFORM UNTIL 88-No-Switch-Changes
1127
+ ACCEPT
1128
+ Switches-Screen
1129
+ END-ACCEPT
1130
+ IF COB-CRT-STATUS > 0
1131
+ EVALUATE COB-CRT-STATUS
1132
+ WHEN COB-SCR-F1
1133
+ IF S-DEBUG = SPACE
1134
+ MOVE Selection-Char TO S-DEBUG
1135
+ ELSE
1136
+ MOVE ' ' TO S-DEBUG
1137
+ END-IF
1138
+ WHEN COB-SCR-F2
1139
+ IF S-DLL = SPACE
1140
+ MOVE Selection-Char TO S-DLL
1141
+ ELSE
1142
+ MOVE ' ' TO S-DLL
1143
+ END-IF
1144
+ WHEN COB-SCR-F3
1145
+ IF S-SUBROUTINE = SPACE
1146
+ MOVE Selection-Char TO S-SUBROUTINE
1147
+ MOVE ' ' TO S-EXECUTE
1148
+ ELSE
1149
+ MOVE ' ' TO S-SUBROUTINE
1150
+ END-IF
1151
+ WHEN COB-SCR-F4
1152
+ IF S-EXECUTE = SPACE
1153
+ AND S-SUBROUTINE = SPACE
1154
+ MOVE Selection-Char TO S-EXECUTE
1155
+ ELSE
1156
+ MOVE ' ' TO S-EXECUTE
1157
+ END-IF
1158
+ WHEN COB-SCR-F5
1159
+ IF S-NOTRUNC = SPACE
1160
+ MOVE Selection-Char TO S-NOTRUNC
1161
+ ELSE
1162
+ MOVE ' ' TO S-NOTRUNC
1163
+ END-IF
1164
+ WHEN COB-SCR-F6
1165
+ IF S-TRACE = SPACE
1166
+ MOVE Selection-Char TO S-TRACE
1167
+ MOVE ' ' TO S-TRACEALL
1168
+ ELSE
1169
+ MOVE ' ' TO S-TRACE
1170
+ END-IF
1171
+ WHEN COB-SCR-F7
1172
+ IF S-TRACEALL = SPACE
1173
+ MOVE Selection-Char TO S-TRACEALL
1174
+ MOVE ' ' TO S-TRACE
1175
+ ELSE
1176
+ MOVE ' ' TO S-TRACEALL
1177
+ END-IF
1178
+ GC0410 WHEN COB-SCR-F8
1179
+ GC0410 IF S-SOURCE = SPACE
1180
+ GC0410 MOVE Selection-Char TO S-SOURCE
1181
+ GC0410 ELSE
1182
+ GC0410 MOVE ' ' TO S-SOURCE
1183
+ GC0410 END-IF
1184
+ GC0410 WHEN COB-SCR-F9
1185
+ GC0410 IF S-XREF = SPACE
1186
+ GC0410 MOVE Selection-Char TO S-XREF
1187
+ GC0410 ELSE
1188
+ GC0410 MOVE ' ' TO S-XREF
1189
+ GC0410 END-IF
1190
+ WHEN COB-SCR-ESC
1191
+ PERFORM 900-Terminate
1192
+ GC0310 WHEN CK-S-F1
1193
+ MOVE SPACES TO S-CfgS
1194
+ MOVE Selection-Char TO S-Cfg-BS2000
1195
+ GC0310 WHEN CK-S-F2
1196
+ MOVE SPACES TO S-CfgS
1197
+ MOVE Selection-Char TO S-Cfg-COBOL85
1198
+ GC0310 WHEN CK-S-F3
1199
+ MOVE SPACES TO S-CfgS
1200
+ MOVE Selection-Char TO S-Cfg-COBOL2002
1201
+ GC0310 WHEN CK-S-F4
1202
+ MOVE SPACES TO S-CfgS
1203
+ MOVE Selection-Char TO S-Cfg-DEFAULT
1204
+ GC0310 WHEN CK-S-F5
1205
+ MOVE SPACES TO S-CfgS
1206
+ MOVE Selection-Char TO S-Cfg-IBM
1207
+ GC0310 WHEN CK-S-F6
1208
+ MOVE SPACES TO S-CfgS
1209
+ MOVE Selection-Char TO S-Cfg-MF
1210
+ GC0310 WHEN CK-S-F7
1211
+ MOVE SPACES TO S-CfgS
1212
+ MOVE Selection-Char TO S-Cfg-MVS
1213
+ WHEN OTHER
1214
+ MOVE 'An unsupported key was pressed'
1215
+ TO Output-Message
1216
+ END-EVALUATE
1217
+ ELSE
1218
+ SET 88-No-Switch-Changes TO TRUE
1219
+ END-IF
1220
+ END-PERFORM
1221
+ .
1222
+
1223
+ 209-Done.
1224
+ EXIT.
1225
+ /
1226
+ 210-Run-Compiler SECTION.
1227
+ *****************************************************************
1228
+ ** Run the compiler using the switch settings we've prepared. **
1229
+ *****************************************************************
1230
+
1231
+ 211-Init.
1232
+ MOVE SPACES TO Cmd
1233
+ Cobc-Cmd
1234
+ Output-Message
1235
+ DISPLAY
1236
+ Switches-Screen
1237
+ END-DISPLAY
1238
+ MOVE 1 TO I
1239
+ EVALUATE TRUE
1240
+ WHEN S-Cfg-BS2000 NOT = SPACES
1241
+ MOVE 'bs2000' TO Config-File
1242
+ WHEN S-Cfg-COBOL85 NOT = SPACES
1243
+ MOVE 'cobol85' TO Config-File
1244
+ WHEN S-Cfg-COBOL2002 NOT = SPACES
1245
+ MOVE 'cobol2002' TO Config-File
1246
+ WHEN S-Cfg-IBM NOT = SPACES
1247
+ MOVE 'ibm' TO Config-File
1248
+ WHEN S-Cfg-MF NOT = SPACES
1249
+ MOVE 'mf' TO Config-File
1250
+ WHEN S-Cfg-MVS NOT = SPACES
1251
+ MOVE 'mvs' TO Config-File
1252
+ WHEN OTHER
1253
+ MOVE 'default' TO Config-File
1254
+ END-EVALUATE
1255
+ .
1256
+
1257
+ 212-Build-Compile-Command.
1258
+ GC0909 MOVE SPACES TO Cobc-Cmd
1259
+ GC0909 STRING 'cobc -std='
1260
+ GC0909 TRIM(Config-File,TRAILING)
1261
+ GC0909 ' '
1262
+ GC0909 INTO Cobc-Cmd
1263
+ GC0909 WITH POINTER I
1264
+ GC0909 END-STRING
1265
+ IF S-SUBROUTINE NOT = ' '
1266
+ STRING '-m '
1267
+ DELIMITED SIZE INTO Cobc-Cmd
1268
+ WITH POINTER I
1269
+ END-STRING
1270
+ ELSE
1271
+ STRING '-x '
1272
+ DELIMITED SIZE INTO Cobc-Cmd
1273
+ WITH POINTER I
1274
+ END-STRING
1275
+ END-IF
1276
+ IF S-DEBUG NOT = ' '
1277
+ STRING '-fdebugging-line '
1278
+ DELIMITED SIZE INTO Cobc-Cmd
1279
+ WITH POINTER I
1280
+ END-STRING
1281
+ END-IF
1282
+ IF S-NOTRUNC NOT = ' '
1283
+ STRING '-fnotrunc '
1284
+ DELIMITED SIZE INTO Cobc-Cmd
1285
+ WITH POINTER I
1286
+ END-STRING
1287
+ END-IF
1288
+ IF S-TRACEALL NOT = ' '
1289
+ GC0809 STRING '-ftraceall '
1290
+ DELIMITED SIZE INTO Cobc-Cmd
1291
+ WITH POINTER I
1292
+ END-STRING
1293
+ END-IF
1294
+ IF S-TRACE NOT = ' '
1295
+ STRING '-ftrace '
1296
+ DELIMITED SIZE INTO Cobc-Cmd
1297
+ WITH POINTER I
1298
+ END-STRING
1299
+ END-IF
1300
+
1301
+ GC0709 IF S-EXTRA > SPACES
1302
+ GC0709 STRING ' '
1303
+ GC0709 TRIM(S-Extra,TRAILING)
1304
+ GC0709 ' '
1305
+ GC0709 DELIMITED SIZE INTO Cobc-Cmd
1306
+ GC0709 WITH POINTER I
1307
+ GC0709 END-STRING
1308
+ GC0709 END-IF
1309
+ GC0909 STRING TRIM(Prog-File-Name,TRAILING)
1310
+ GC0909 DELIMITED SIZE INTO Cobc-Cmd
1311
+ GC0909 WITH POINTER I
1312
+ GC0909 END-STRING
1313
+ .
1314
+
1315
+ 213-Run-Compiler.
1316
+ GC0410 MOVE ' Compiling...' TO Output-Message
1317
+ GC0410 DISPLAY
1318
+ GC0410 Switches-Screen
1319
+ GC0410 END-DISPLAY
1320
+ GC0609 SET 88-Output-File-Avail TO TRUE
1321
+ MOVE SPACES TO Cmd
1322
+ STRING TRIM(Cobc-Cmd,TRAILING)
1323
+ ' 2>'
1324
+ TRIM(Cobc-Output-File,TRAILING)
1325
+ DELIMITED SIZE
1326
+ INTO Cmd
1327
+ END-STRING
1328
+ CALL 'SYSTEM'
1329
+ USING TRIM(Cmd,TRAILING)
1330
+ END-CALL
1331
+ GC0909 IF RETURN-CODE = 0
1332
+ GC0909 SET 88-Compile-OK TO TRUE
1333
+ GC0909 ELSE
1334
+ GC0909 SET 88-Compile-Failed TO TRUE
1335
+ GC0909 END-IF
1336
+ GC0909 IF 88-Compile-OK
1337
+ GC0909 OPEN INPUT Cobc-Output
1338
+ GC0909 READ Cobc-Output
1339
+ GC0909 AT END
1340
+ GC0909 CONTINUE
1341
+ GC0909 NOT AT END
1342
+ GC0909 SET 88-Compile-OK-Warn TO TRUE
1343
+ GC0909 END-READ
1344
+ GC0909 CLOSE Cobc-Output
1345
+ GC0909 END-IF
1346
+ GC0909 MOVE SPACES TO Output-Message
1347
+ IF 88-Compile-OK
1348
+ GC0909 MOVE ' Compilation Was Successful' TO Output-Message
1349
+ GC0909 DISPLAY
1350
+ GC0909 Switches-Screen
1351
+ GC0909 END-DISPLAY
1352
+ GC0909 CALL 'C$SLEEP'
1353
+ GC0909 USING 2
1354
+ GC0909 END-CALL
1355
+ GC0909 MOVE SPACES TO Output-Message
1356
+ GC0609 SET 88-Complete TO TRUE
1357
+ ELSE
1358
+ GC0909 DISPLAY
1359
+ GC0909 Blank-Screen
1360
+ GC0909 END-DISPLAY
1361
+ GC0909 IF 88-Compile-OK-Warn
1362
+ GC0909 DISPLAY ' Compilation was successful, but ' &
1363
+ GC0909 'warnings were generated:'
1364
+ SCROLL* AT LINE 24 COLUMN 1
1365
+ SCROLL* WITH SCROLL UP 1 LINE
1366
+ GC0909 END-DISPLAY
1367
+ GC0909 ELSE
1368
+ GC0909 DISPLAY 'Compilation Failed:'
1369
+ SCROLL* AT LINE 24 COLUMN 1
1370
+ SCROLL* WITH SCROLL UP 1 LINE
1371
+ GC0909 END-DISPLAY
1372
+ GC0909 END-IF
1373
+ GC0609 SET 88-Compile-Failed TO TRUE
1374
+ GC0609 SET 88-Complete TO TRUE
1375
+ GC0909 DISPLAY ' '
1376
+ SCROLL* AT LINE 24 COLUMN 1
1377
+ SCROLL* WITH SCROLL UP 1 LINE
1378
+ GC0909 END-DISPLAY
1379
+ GC0909 OPEN INPUT Cobc-Output
1380
+ GC0909 PERFORM FOREVER
1381
+ GC0909 READ Cobc-Output AT END
1382
+ GC0909 EXIT PERFORM
1383
+ GC0909 END-READ
1384
+ GC0909 DISPLAY TRIM(Cobc-Output-Rec,TRAILING)
1385
+ SCROLL* AT LINE 24 COLUMN 1
1386
+ SCROLL* WITH SCROLL UP 1 LINE
1387
+ GC0909 END-DISPLAY
1388
+ GC0909 END-PERFORM
1389
+ GC0909 CLOSE Cobc-Output
1390
+ GC0909 DISPLAY ' '
1391
+ SCROLL* AT LINE 24 COLUMN 1
1392
+ SCROLL* WITH SCROLL UP 2 LINES
1393
+ GC0909 END-DISPLAY
1394
+ GC0909 DISPLAY 'Press ENTER to close:'
1395
+ SCROLL* AT LINE 24 COLUMN 1
1396
+ SCROLL* WITH SCROLL UP 1 LINE
1397
+ GC0909 END-DISPLAY
1398
+ GC0909 ACCEPT Dummy
1399
+ GC0909 FROM CONSOLE
1400
+ GC0909 END-ACCEPT
1401
+ GC0909 DISPLAY
1402
+ GC0909 Blank-Screen
1403
+ GC0909 END-DISPLAY
1404
+ END-IF
1405
+ .
1406
+
1407
+ 219-Done.
1408
+ IF 88-Compile-Failed
1409
+ PERFORM 900-Terminate
1410
+ END-IF
1411
+ .
1412
+ /
1413
+ GC0410 220-Make-Listing SECTION.
1414
+ GC0410*****************************************************************
1415
+ GC0410** Generate a source and/or xref listing using XREF **
1416
+ GC0410*****************************************************************
1417
+ GC0410
1418
+ GC0410 221-Init.
1419
+ GC0410 MOVE ' Generating cross-reference listing...'
1420
+ GC0410 TO Output-Message
1421
+ GC0410 DISPLAY
1422
+ GC0410 Switches-Screen
1423
+ GC0410 END-DISPLAY
1424
+ GC0410 CALL "CBL_DELETE_FILE"
1425
+ GC0410 USING CONCATENATE(TRIM(Prog-Name,Trailing),".lst")
1426
+ GC0410 END-CALL
1427
+ GC0410 MOVE 0 TO RETURN-CODE
1428
+ GC0410 .
1429
+ GC0410
1430
+ GC0410 213-Run-OCXref.
1431
+ GC0410 MOVE SPACES TO Output-Message
1432
+ GC0410 CALL 'LISTING'
1433
+ GC0410 USING S-SOURCE
1434
+ GC0410 S-XREF
1435
+ GC0410 File-Name
1436
+ GC0410 ON EXCEPTION
1437
+ GC0410 MOVE ' LISTING module is not available'
1438
+ GC0410 TO Output-Message
1439
+ GC0410 MOVE 1 TO RETURN-CODE
1440
+ GC0410 END-CALL
1441
+ GC0410 IF RETURN-CODE = 0
1442
+ GC0410 MOVE ' Listing generated'
1443
+ GC0410 TO Output-Message
1444
+ GC0410 IF OS-Windows OR OS-Cygwin
1445
+ GC0410 MOVE SPACES TO Cmd
1446
+ GC0410 STRING
1447
+ GC0410 'cmd /c '
1448
+ GC0410 TRIM(Prog-Name,TRAILING)
1449
+ GC0410 '.lst'
1450
+ GC0410 DELIMITED SIZE INTO Cmd
1451
+ GC0410 END-STRING
1452
+ GC0410 CALL 'SYSTEM'
1453
+ GC0410 USING TRIM(Cmd,TRAILING)
1454
+ GC0410 END-CALL
1455
+ GC0410 END-IF
1456
+ GC0410 ELSE
1457
+ GC0410 IF Output-Message = SPACES
1458
+ GC0410 MOVE ' Listing generation failed'
1459
+ GC0410 TO Output-Message
1460
+ GC0410 END-IF
1461
+ GC0410 END-IF
1462
+ GC0410 DISPLAY
1463
+ GC0410 Switches-Screen
1464
+ GC0410 END-DISPLAY
1465
+ GC0410 CALL 'C$SLEEP'
1466
+ GC0410 USING 2
1467
+ GC0410 END-CALL
1468
+ GC0410 .
1469
+ /
1470
+ 230-Run-Program SECTION.
1471
+ *****************************************************************
1472
+ ** Run the compiled program **
1473
+ *****************************************************************
1474
+
1475
+ 232-Build-Command.
1476
+ GC0909 MOVE SPACES TO Cmd
1477
+ GC0909 MOVE 1 TO I
1478
+ IF S-SUBROUTINE NOT = ' '
1479
+ OR S-DLL NOT = ' '
1480
+ STRING 'cobcrun ' DELIMITED SIZE
1481
+ INTO Cmd
1482
+ WITH POINTER I
1483
+ END-STRING
1484
+ END-IF
1485
+ IF Prog-Folder NOT = SPACES
1486
+ GC0909 IF OS-Cygwin AND Prog-Folder (2:1) = ':'
1487
+ GC0909 STRING '/cygdrive/'
1488
+ GC0909 INTO Cmd
1489
+ GC0909 WITH POINTER I
1490
+ GC0909 END-STRING
1491
+ GC0909 STRING LOWER-CASE(Prog-Folder (1:1))
1492
+ GC0909 INTO Cmd
1493
+ GC0909 WITH POINTER I
1494
+ GC0909 END-STRING
1495
+ GC0909 PERFORM VARYING J FROM 3 BY 1
1496
+ GC0909 UNTIL J > LENGTH(TRIM(Prog-Folder))
1497
+ GC0909 IF Prog-Folder (J:1) = '\'
1498
+ GC0909 STRING '/'
1499
+ GC0909 INTO Cmd
1500
+ GC0909 WITH POINTER I
1501
+ GC0909 END-STRING
1502
+ GC0909 ELSE
1503
+ GC0909 STRING Prog-Folder (J:1)
1504
+ GC0909 INTO Cmd
1505
+ GC0909 WITH POINTER I
1506
+ GC0909 END-STRING
1507
+ GC0909 END-IF
1508
+ GC0909 END-PERFORM
1509
+ GC0909 ELSE
1510
+ GC0410 STRING '"' TRIM(Prog-Folder,TRAILING)
1511
+ GC0909 INTO Cmd
1512
+ GC0909 WITH POINTER I
1513
+ GC0909 END-STRING
1514
+ GC0909 END-IF
1515
+ GC0909 STRING Dir-Char
1516
+ GC0909 INTO Cmd
1517
+ GC0909 WITH POINTER I
1518
+ GC0909 END-STRING
1519
+ GC0909 ELSE
1520
+ GC0909 IF OS-Cygwin OR OS-UNIX
1521
+ GC0909 STRING './'
1522
+ GC0909 INTO Cmd
1523
+ GC0909 WITH POINTER I
1524
+ GC0909 END-STRING
1525
+ GC0909 END-IF
1526
+ END-IF
1527
+ GC0909 STRING TRIM(Prog-Name,TRAILING)
1528
+ GC0909 INTO Cmd
1529
+ GC0909 WITH POINTER I
1530
+ GC0909 END-STRING
1531
+ GC0909 IF S-SUBROUTINE = ' '
1532
+ GC0909 AND S-DLL NOT = ' '
1533
+ GC0909 STRING '.exe' DELIMITED SIZE
1534
+ INTO Cmd
1535
+ WITH POINTER I
1536
+ END-STRING
1537
+ END-IF
1538
+ IF S-ARGS NOT = SPACES
1539
+ GC0809 STRING ' ' TRIM(S-ARGS,TRAILING)
1540
+ INTO Cmd
1541
+ WITH POINTER I
1542
+ END-STRING
1543
+ END-IF
1544
+ IF OS-Unknown OR OS-Windows
1545
+ GC0410 STRING '"&&pause'
1546
+ INTO Cmd
1547
+ WITH POINTER I
1548
+ END-STRING
1549
+ ELSE
1550
+ STRING ';echo "Press ENTER to close...";read'
1551
+ INTO Cmd
1552
+ WITH POINTER I
1553
+ END-STRING
1554
+ END-IF
1555
+ .
1556
+
1557
+ 233-Run-Program.
1558
+ GC0909 DISPLAY
1559
+ GC0909 Blank-Screen
1560
+ GC0909 END-DISPLAY
1561
+
1562
+ CALL 'SYSTEM'
1563
+ USING TRIM(Cmd,TRAILING)
1564
+ END-CALL
1565
+ PERFORM 900-Terminate
1566
+ .
1567
+
1568
+ 239-Done.
1569
+ EXIT.
1570
+ /
1571
+ 900-Terminate SECTION.
1572
+ *****************************************************************
1573
+ ** Display a message and halt the program **
1574
+ *****************************************************************
1575
+
1576
+ 901-Display-Message.
1577
+ GC0909 IF Output-Message > SPACES
1578
+ GC0909 DISPLAY
1579
+ GC0909 Switches-Screen
1580
+ GC0909 END-DISPLAY
1581
+ GC0909 CALL 'C$SLEEP'
1582
+ GC0909 USING 2
1583
+ GC0909 END-CALL
1584
+ GC0909 END-IF
1585
+ DISPLAY
1586
+ Blank-Screen
1587
+ END-DISPLAY
1588
+ .
1589
+
1590
+ 909-Done.
1591
+ GOBACK
1592
+ .
1593
+
1594
+ END PROGRAM OCic.
1595
+
1596
+ IDENTIFICATION DIVISION.
1597
+ PROGRAM-ID. GETOSTYPE.
1598
+ *****************************************************************
1599
+ ** This subprogram determine the OS type the program is run- **
1600
+ ** ning under, passing that result back in RETURN-CODE as fol- **
1601
+ ** lows: **
1602
+ ** **
1603
+ ** 0: Cannot be determined **
1604
+ ** 1: Native Windows or Windows/MinGW **
1605
+ ** 2: Cygwin **
1606
+ ** 3: UNIX/Linux/MacOS **
1607
+ *****************************************************************
1608
+ ** DATE CHANGE DESCRIPTION **
1609
+ ** ====== ==================================================== **
1610
+ ** GC0909 Initial coding. **
1611
+ *****************************************************************
1612
+ ENVIRONMENT DIVISION.
1613
+ CONFIGURATION SECTION.
1614
+ REPOSITORY.
1615
+ FUNCTION ALL INTRINSIC.
1616
+ DATA DIVISION.
1617
+ WORKING-STORAGE SECTION.
1618
+ 01 Env-Path PIC X(1024).
1619
+ 01 Tally USAGE BINARY-LONG.
1620
+ PROCEDURE DIVISION.
1621
+ 000-Main SECTION.
1622
+ 010-Get-TEMP-Var.
1623
+ MOVE SPACES TO Env-Path
1624
+ ACCEPT Env-Path
1625
+ FROM ENVIRONMENT "PATH"
1626
+ ON EXCEPTION
1627
+ MOVE 0 TO RETURN-CODE
1628
+ GOBACK
1629
+ END-ACCEPT
1630
+ IF Env-Path = SPACES
1631
+ MOVE 0 TO RETURN-CODE
1632
+ ELSE
1633
+ MOVE 0 TO Tally
1634
+ INSPECT Env-Path
1635
+ TALLYING Tally FOR ALL ";"
1636
+ IF Tally = 0 *> Must be some form of UNIX
1637
+ MOVE 0 TO Tally
1638
+ INSPECT Env-Path
1639
+ TALLYING TALLY FOR ALL "/cygdrive/"
1640
+ IF Tally = 0 *> UNIX/MacOS
1641
+ MOVE 3 TO RETURN-CODE
1642
+ ELSE *> Cygwin
1643
+ MOVE 2 TO RETURN-CODE
1644
+ END-IF
1645
+ ELSE *> Assume Windows[/MinGW]
1646
+ MOVE 1 TO RETURN-CODE
1647
+ END-IF
1648
+ END-IF
1649
+ GOBACK
1650
+ .
1651
+ END PROGRAM GETOSTYPE.
1652
+
1653
+ IDENTIFICATION DIVISION.
1654
+ PROGRAM-ID. CHECKSOURCE.
1655
+ *****************************************************************
1656
+ ** This subprogram will scan a line of source code it is given **
1657
+ ** looking for "LINKAGE SECTION" or "IDENTIFICATION DIVISION". **
1658
+ ** **
1659
+ ** ****NOTE**** ****NOTE**** ****NOTE**** ****NOTE*** **
1660
+ ** **
1661
+ ** These two strings must be found IN THEIR ENTIRETY within **
1662
+ ** the 1st 80 columns of program source records, and cannot **
1663
+ ** follow either a "*>" sequence OR a "*" in col 7. **
1664
+ *****************************************************************
1665
+ ** DATE CHANGE DESCRIPTION **
1666
+ ** ====== ==================================================== **
1667
+ ** GC0809 Initial coding. **
1668
+ *****************************************************************
1669
+ ENVIRONMENT DIVISION.
1670
+ CONFIGURATION SECTION.
1671
+ REPOSITORY.
1672
+ FUNCTION ALL INTRINSIC.
1673
+ DATA DIVISION.
1674
+ WORKING-STORAGE SECTION.
1675
+ 01 Compressed-Src.
1676
+ 05 CS-Char OCCURS 80 TIMES PIC X(1).
1677
+
1678
+ 01 Flags.
1679
+ 05 F-Found-SPACE PIC X(1).
1680
+ 88 88-Skipping-SPACE VALUE 'Y'.
1681
+ 88 88-Not-Skipping-SPACE VALUE 'N'.
1682
+
1683
+ 01 I USAGE BINARY-CHAR.
1684
+
1685
+ 01 J USAGE BINARY-CHAR.
1686
+ LINKAGE SECTION.
1687
+ 01 Argument-1.
1688
+ 02 A1-Char OCCURS 80 TIMES PIC X(1).
1689
+
1690
+ 01 Argument-2 PIC X(1).
1691
+ 88 88-A2-LINKAGE-SECTION VALUE 'L'.
1692
+ 88 88-A2-IDENTIFICATION-DIVISION VALUE 'I'.
1693
+ 88 88-A2-Nothing-Special VALUE ' '.
1694
+ PROCEDURE DIVISION USING Argument-1, Argument-2.
1695
+ 000-Main SECTION.
1696
+
1697
+ 010-Initialize.
1698
+ SET 88-A2-Nothing-Special TO TRUE
1699
+ IF A1-Char (7) = '*'
1700
+ GOBACK
1701
+ END-IF
1702
+ .
1703
+
1704
+ 020-Compress-Multiple-SPACES.
1705
+ SET 88-Not-Skipping-SPACE TO TRUE
1706
+ MOVE 0 TO J
1707
+ MOVE SPACES TO Compressed-Src
1708
+ PERFORM VARYING I FROM 1 BY 1
1709
+ UNTIL I > 80
1710
+ IF A1-Char (I) = SPACE
1711
+ IF 88-Not-Skipping-SPACE
1712
+ ADD 1 TO J
1713
+ MOVE UPPER-CASE(A1-Char (I)) TO CS-Char (J)
1714
+ SET 88-Skipping-SPACE TO TRUE
1715
+ END-IF
1716
+ ELSE
1717
+ SET 88-Not-Skipping-SPACE TO TRUE
1718
+ ADD 1 TO J
1719
+ MOVE A1-Char (I) TO CS-Char (J)
1720
+ END-IF
1721
+ END-PERFORM
1722
+ .
1723
+
1724
+ 030-Scan-Compressed-Src.
1725
+ PERFORM VARYING I FROM 1 BY 1
1726
+ UNTIL I > 66
1727
+ EVALUATE TRUE
1728
+ WHEN CS-Char (I) = '*'
1729
+ IF Compressed-Src (I : 2) = '*>'
1730
+ GOBACK
1731
+ END-IF
1732
+ WHEN (CS-Char (I) = 'L') AND (I < 66)
1733
+ IF Compressed-Src (I : 15) = 'LINKAGE SECTION'
1734
+ SET 88-A2-LINKAGE-SECTION TO TRUE
1735
+ GOBACK
1736
+ END-IF
1737
+ WHEN (CS-Char (I) = 'I') AND (I < 58)