version 0.73.0

This commit is contained in:
2023-07-14 12:15:30 -03:00
parent 110d8a0419
commit 945dd1a809
1466 changed files with 374820 additions and 0 deletions
+339
View File
@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
+49
View File
@@ -0,0 +1,49 @@
#
# Makefile para compilar programas.
COB := htcobol
CCX := gcc
RM := rm -f
INSTALL := install -m 755
COBFLAGS := -c -F -T 8
CCXFLAGS := -g -o
COPYBOOKS := -I.
LIBS := -lhtcobol
BINDIR := /usr/local/bin
SRC1 := cbl2cob.cob
SRC2 := mfparser.cob
SRC3 := mbparser.cob
OBJ1 := $(SRC1:.cob=.o)
OBJ2 := $(SRC2:.cob=.o)
OBJ3 := $(SRC3:.cob=.o)
PROG1 := $(SRC1:.cob= )
OBJS1 := $(OBJ1) $(OBJ2) $(OBJ3)
OBJS := $(OBJ1) $(OBJ2) $(OBJ3)
#OBJS1 := $(OBJ1) $(OBJ2)
#OBJS := $(OBJ1) $(OBJ2)
PROGS := $(PROG1)
all: $(OBJS) $(PROGS)
$(PROG1): $(OBJS1)
$(CCX) $(CCXFLAGS) $(PROG1) $(OBJS1) $(LIBS)
# Rules to compile COBOL programs to assembly object code.
%.o: %.cob
$(COB) $(COBFLAGS) $<
# Rules to generate binary programs from object code.
%: %.o
$(CCX) $(CCXFLAGS) $@ $< $(LIBS)
clean:
$(RM) $(OBJS) $(PROGS) *.i *.s
install:
$(INSTALL) $(PROG1) $(BINDIR)
+59
View File
@@ -0,0 +1,59 @@
STATUS:
-------
- Temos suporte para dois compiladores, MF e MB.
- Para usar o cbl2cob e converter para o microbase, use a opção "-d mb".
- Para executar os exemplos de conversão, vá até o diretório samples e
digite "Make -f Makefile.Mb".
Até o presente momento o cbl2cob faz as seguintes ações:
- Adiciona IDENTIFICATION DIVISION se preciso.
- Adiciona PROGRAM-ID se preciso.
- Converte conteúdo da PROGRAM-ID em minúsculo.
- Retira clausulas LOCK MODE.
- Retira clausulas DATA RECORD.
- Retira cláusulas VALUE OF FILE-ID.
- Acerta caracteres de continuacao de linha(simples ou duplos),
modificando-os de estarem na coluna 9 para a coluna 12.
- DISPLAY.
- Substituir clausula DISPLAY AT LINE .. COLUMN .. por DISPLAY AT ....
- Retirar clausulas BACKGROUND-COLOR, FOREGROUND-COLOR, BELL e PROMPT
- Substituir parametro AUTO-SKIP por AUTO.
- ACCEPT.
- Substituir clausula DISPLAY AT LINE .. COLUMN .. por DISPLAY AT ....
- Retirar clausulas BACKGROUND-COLOR, FOREGROUND-COLOR e PROMPT
- Substituir parametro AUTO-SKIP por AUTO.
- Remover clausula ACCEPT FROM ESCAPE KEY.
- Insere CRT STATUS IS <VARIAVEL-TECLA>.
- CALL e CANCEL
- Transforma o conteúdo entre aspas em lowercase
- Remove funcoes X"AF".
- Remove funcoes X"91".
- SELECT.
- Substitui ASSIGN TO <nome-arquivo> para ASSIGN TO EXTERNAL <nome-arquivo>
- Substitui ASSIGN TO DISK por ASSIGN TO EXTERNAL <nome-arquivo>
- Substitui ASSIGN TO PRINTER por ASSIGN TO EXTERNAL printer
- Substitui "\" por "/" nas strings.
- MOVE.
- Retirar "$" nas strings.
- Substituir "\" por "/" nas strings.
- DELETE.
- Remove a cláusula FILE, se usada junto com o DELETE.
- Pre-processa(abre/fecha) fontes, com o verbo COPY.
Futuramente, será implementado as seguintes ações:
- Inserir inteligencia no parser para indentar as linhas de continuacao
corretamente.
- Inserir inteligencia no parser para remover instrucoes que tenham mais
de uma linha.
- Inserir inteligencia no parser para usar diversas variaveis de arquivo.
- Substituir assign to PRINTER por assign to <nome-arquivo>
Inserir chamada SYSTEM.
- Substituir rotinas x"91" por rotina "cbl_call_system"
- Substituir rotinas x"AF" por rotina "cbl_read_kbd_char"
- Substituir rotinas x"B8" por rotina ...
- Substituir rotinas PC_PRINTER por rotina ...
- Substituir CBL_READ_SCR_CHATTRS por rotina cbl_read_scr_chattrs
- Substituir CBL_WRITE_SCR_CHATTRS por rotina cbl_write_scr_chattrs
+561
View File
@@ -0,0 +1,561 @@
*
* Copyright (C) 2003, Hudson Reis,
* Infocont Sistemas Integrados Ltda.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; see the file COPYING.
* If not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*
identification division.
program-id. cbl2cob.
author. Hudson Reis.
date-written. 03/05/2003.
*
* Front-end para pré-processar o fonte de entrada e chamar o
* parser selecionado, mediante a escolha do usuário.
*
environment division.
configuration section.
input-output section.
file-control.
copy "entrada.sl".
copy "intermed.sl".
copy "saida.sl".
data division.
file section.
copy "entrada.fd".
copy "intermed.fd".
copy "saida.fd".
working-storage section.
copy "globals.ws".
copy "globals.ls".
77 filler pic x(001) value spaces.
* Linha de comando para pegar a string digitada pelo usuario.
77 ws77-linha-comando pic x(512) value spaces.
* Variáveis que serão usadas para quebrar a frase
* passada na linha de comando, pelo usuário.
* O número máximo argumentos supotados é 8.
01 ws01-args.
02 ws02-arg-a pic x(256) value spaces.
02 ws02-arg-b pic x(256) value spaces.
02 ws02-arg-c pic x(256) value spaces.
02 ws02-arg-d pic x(256) value spaces.
02 ws02-arg-e pic x(256) value spaces.
02 ws02-arg-f pic x(256) value spaces.
02 ws02-arg-g pic x(256) value spaces.
02 ws02-arg-h pic x(256) value spaces.
* Lugar temporário para a switch do dialeto selecionado.
77 ws77-dialeto-selecionado pic x(256) value spaces.
* Variáveis para os dialetos.
77 ws77-dialeto-entrada pic x(003) value spaces.
88 ws88-microbase value "mb".
88 ws88-microfocus value "mf".
88 ws88-rm value "rm".
* Variável para determinar se o dado a ser tratado é um valor
* ou uma switch.
77 ws77-dado pic 9(001) value zeros.
88 ws88-switch value 0.
88 ws88-valor value 1.
* Opções do pre-processador.
77 ws77-opcoes-pp pic 9(001) value zeros.
88 ws88-abrir-copybooks value 0.
88 ws88-fechar-copybooks value 1.
* Variáveis que vão armazenar o basename de cada arquivo, caso
* o usuário indique um diretório externo ao diretório corrente
77 ws77-basename-entrada pic x(256) value spaces.
77 ws77-basename-saida pic x(256) value spaces.
* Variáveis com o valor das switches selecionadas.
77 ws77-escolher-dialeto pic x(002) value "-d".
77 ws77-mostrar-ajuda pic x(002) value "-h".
77 ws77-fonte-entrada pic x(002) value "-i".
77 ws77-fonte-saida pic x(002) value "-o".
77 ws77-modo-verboso pic x(002) value "-v".
77 ws77-exibir-versao pic x(002) value "-V".
* A otimizar.
77 ws77-linha-para-parsing pic x(256) value spaces.
01 ws01-case.
02 ws02-maiusculo pic x(26)
value "ABCDEFGHIJKLMNOPQRSTUVXYWZ".
02 ws02-minusculo pic x(26)
value "abcdefghijklmnopqrstuvxywz".
procedure division.
perform ler-linha-de-comando
set ws88-abrir-copybooks to true
perform pre-processar-fonte
evaluate true
when ws88-microfocus
call "mfparser" using ws77-arquivo-entrada
ws77-arquivo-saida
ws77-processo
end-call
when ws88-microbase
call "mbparser" using ws77-arquivo-entrada
ws77-arquivo-saida
ws77-processo
end-call
end-evaluate
* set ws88-fechar-copybooks to true
* perform pre-processar-fonte
perform finalizar
.
*****************************************************************
* Rotinas principais *
*****************************************************************
ler-linha-de-comando.
* 1a. Etapa: Lendo as opções da linha de comando.
accept ws77-linha-comando from command-line
if return-code not equal zeros
display "Tamanho da linha de comando truncada!"
perform finalizar
end-if
if ws88-processo-verboso
display "Linha de comando: " ws77-linha-comando
end-if
unstring ws77-linha-comando delimited by ' ' into
ws02-arg-a
ws02-arg-b
ws02-arg-c
ws02-arg-d
ws02-arg-e
ws02-arg-f
ws02-arg-g
ws02-arg-h
end-unstring
if ws88-processo-verboso
perform varying ws02-i from 256 by -1
until ws02-arg-a(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "Argumento a: " ws02-arg-a(1:ws02-i)
perform varying ws02-i from 256 by -1
until ws02-arg-b(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "Argumento b: " ws02-arg-b(1:ws02-i)
perform varying ws02-i from 256 by -1
until ws02-arg-c(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "Argumento c: " ws02-arg-c(1:ws02-i)
perform varying ws02-i from 256 by -1
until ws02-arg-d(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "Argumento d: " ws02-arg-d(1:ws02-i)
perform varying ws02-i from 256 by -1
until ws02-arg-e(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "Argumento e: " ws02-arg-e(1:ws02-i)
perform varying ws02-i from 256 by -1
until ws02-arg-f(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "Argumento f: " ws02-arg-f(1:ws02-i)
perform varying ws02-i from 256 by -1
until ws02-arg-g(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "Argumento g: " ws02-arg-g(1:ws02-i)
perform varying ws02-i from 256 by -1
until ws02-arg-h(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "Argumento h: " ws02-arg-h(1:ws02-i)
end-if
if ws88-switch
evaluate ws02-arg-b
when ws77-escolher-dialeto
move ws02-arg-c to ws77-dialeto-selecionado
perform escolher-dialeto
when ws77-mostrar-ajuda
perform exibir-ajuda
when ws77-fonte-entrada
move ws02-arg-c to ws77-arquivo-entrada
perform verificar-arquivo-entrada
when ws77-modo-verboso
set ws88-processo-verboso to true
when ws77-exibir-versao
perform exibir-versao
when other
perform exibir-ajuda
end-evaluate
else
set ws88-valor to true
end-if
if ws88-switch
evaluate ws02-arg-c
when ws77-escolher-dialeto
move ws02-arg-d to ws77-dialeto-selecionado
perform escolher-dialeto
when ws77-fonte-entrada
move ws02-arg-d to ws77-arquivo-entrada
perform verificar-arquivo-entrada
when ws77-modo-verboso
set ws88-processo-verboso to true
when other
perform exibir-ajuda
end-evaluate
else
set ws88-switch to true
end-if
if ws88-continua-parsing
if ws88-switch
evaluate ws02-arg-d
when ws77-modo-verboso
set ws88-processo-verboso to true
when ws77-fonte-entrada
move ws02-arg-e to ws77-arquivo-entrada
perform verificar-arquivo-entrada
when ws77-fonte-saida
move ws02-arg-e to ws77-arquivo-saida
perform verificar-arquivo-saida
when other
perform exibir-ajuda
end-evaluate
else
set ws88-switch to true
end-if
end-if
if ws88-continua-parsing
if ws88-switch
evaluate ws02-arg-e
when ws77-fonte-entrada
move ws02-arg-f to ws77-arquivo-entrada
perform verificar-arquivo-entrada
when ws77-fonte-saida
move ws02-arg-f to ws77-arquivo-saida
perform verificar-arquivo-saida
when other
perform exibir-ajuda
end-evaluate
else
set ws88-switch to true
end-if
end-if
if ws88-continua-parsing
if ws88-switch
evaluate ws02-arg-f
when ws77-fonte-entrada
move ws02-arg-g to ws77-arquivo-entrada
perform verificar-arquivo-entrada
when ws77-fonte-saida
move ws02-arg-g to ws77-arquivo-saida
perform verificar-arquivo-saida
when other
perform exibir-ajuda
end-evaluate
else
set ws88-switch to true
end-if
end-if
if ws88-continua-parsing
if ws88-switch
evaluate ws02-arg-g
when ws77-fonte-saida
move ws02-arg-h to ws77-arquivo-saida
perform verificar-arquivo-saida
when other
perform exibir-ajuda
end-evaluate
else
set ws88-switch to true
end-if
end-if
if ws77-dialeto-entrada equal spaces
display "Erro na escolha do dialeto"
perform finalizar
else
if ws88-processo-verboso
evaluate true
when ws88-microbase
display "dialeto: Microbase COBOL"
when ws88-microfocus
display "dialeto: Microfocus COBOL"
when ws88-rm
display "dialeto: RM COBOL"
when other
display "Erro na escolha do dialeto"
perform finalizar
end-evaluate
end-if
end-if
if ws77-arquivo-entrada equal spaces
display "Não foi informado arquivo de entrada"
perform finalizar
else
if ws88-processo-verboso
move zeros to ws02-m
perform varying ws02-m from 256 by -1 until
ws77-arquivo-entrada(ws02-m:1) not equal spaces
continue
end-perform
display "input: " ws77-arquivo-entrada(1:ws02-m)
end-if
end-if
if ws77-arquivo-saida equal spaces
display "Nao foi informado arquivo de saida"
perform finalizar
else
if ws88-processo-verboso
move zeros to ws02-m
perform varying ws02-m from 256 by -1 until
ws77-arquivo-saida(ws02-m:1) not equal spaces
continue
end-perform
display "output: " ws77-arquivo-saida(1:ws02-m)
end-if
end-if
.
pre-processar-fonte.
move ws77-arquivo-entrada
to ws77-arquivo-intermediario
perform varying ws02-i from 256 by -1
until ws77-arquivo-intermediario(ws02-i:1)
not equal spaces
continue
end-perform
add 1 to ws02-i
compute ws02-j = 256 - ws02-i
move ".pre" to ws77-arquivo-intermediario(ws02-i:ws02-j)
if ws88-processo-verboso
add 4 to ws02-i
display "Arquivo intermediario: "
ws77-arquivo-intermediario(1:ws02-i)
end-if
open input arquivo-entrada
if not ws88-ok
perform testar-file-status
end-if
open output arquivo-intermediario
perform until ws88-fim-arquivo
read arquivo-entrada
if not ws88-fim-arquivo
move reg-arquivo-entrada
to ws77-linha-para-parsing
inspect ws77-linha-para-parsing
converting ws02-minusculo
to ws02-maiusculo
move zeros to ws02-i
inspect ws77-linha-para-parsing
tallying ws02-i for all " COPY "
if ws02-i > 0
perform testes-copy
else
write reg-arquivo-intermediario
from reg-arquivo-entrada
end-if
end-if
end-perform
close arquivo-entrada arquivo-intermediario
move ws77-arquivo-intermediario to ws77-arquivo-entrada
.
finalizar.
stop run
.
*****************************************************************
* Procedures secundárias *
*****************************************************************
verificar-arquivo-entrada.
set ws88-continua-parsing to true
set ws88-valor to true
open input arquivo-entrada
if not ws88-ok
perform testar-file-status
end-if
close arquivo-entrada
.
verificar-arquivo-saida.
* Pegar o basename do fonte de entrada.
perform varying ws02-i from 256 by -1
until ws77-arquivo-entrada(ws02-i:1)
not equal spaces
continue
end-perform
* Descobrir o início da string(que pode estar terminado com
* "/")
perform varying ws02-j from ws02-i by -1
until ws77-arquivo-entrada(ws02-j:1)
equal "/" or ws02-j equal zeros
continue
end-perform
if ws77-arquivo-entrada(ws02-j:1) equal "/"
add 1 to ws02-j
compute ws02-k = ws02-i - ws02-j
add 1 to ws02-k
move ws77-arquivo-entrada(ws02-j:ws02-k)
to ws77-basename-entrada
if ws88-processo-verboso
display "input a: "
ws77-arquivo-entrada(ws02-j:ws02-k)
end-if
else
if ws88-processo-verboso
perform varying ws02-i from 256 by -1
until ws77-arquivo-entrada(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "input b: " ws77-arquivo-entrada(1:ws02-i)
end-if
move ws77-arquivo-entrada to ws77-basename-entrada
end-if
if ws77-arquivo-saida equal spaces
display "Arquivo de saída não informado"
perform finalizar
end-if
* Pegar o basename do fonte de saída.
perform varying ws02-l from 256 by -1
until ws77-arquivo-saida(ws02-l:1)
not equal spaces
continue
end-perform
if ws88-processo-verboso
display "ws02-l: " ws02-l
end-if
* Descobrir o início da string(que pode estar terminado com
* "/")
perform varying ws02-m from ws02-l by -1
until ws77-arquivo-saida(ws02-m:1)
equal "/" or ws02-m equal zeros
continue
end-perform
if ws88-processo-verboso
display "ws02-m: " ws02-m
end-if
if ws77-arquivo-saida(ws02-m:1) equal "/"
add 1 to ws02-m
compute ws02-n = ws02-l - ws02-m
add 1 to ws02-n
move ws77-arquivo-saida(ws02-m:ws02-n)
to ws77-basename-saida
if ws88-processo-verboso
display "output a: "
ws77-arquivo-saida(ws02-m:ws02-n)
end-if
else
if ws88-processo-verboso
perform varying ws02-i from 256 by -1
until ws77-arquivo-saida(ws02-i:1)
not equal spaces or ws02-i equal zeros
continue
end-perform
add 1 to ws02-i
display "output b: " ws77-arquivo-saida(1:ws02-i)
end-if
move ws77-arquivo-saida to ws77-basename-saida
end-if
set ws88-finaliza-parsing to true
set ws88-valor to true
if ws77-basename-entrada equal ws77-basename-saida
display "Arquivo de saída igual ao arquivo de entrada"
perform finalizar
end-if
.
escolher-dialeto.
set ws88-valor to true
evaluate ws77-dialeto-selecionado
when "mb "
set ws88-microbase to true
when "mf "
set ws88-microfocus to true
when "rm "
set ws88-rm to true
when other
display "Erro na escolha do dialeto"
perform finalizar
end-evaluate
.
testes-copy.
move zeros to ws02-i
inspect ws77-linha-para-parsing
tallying ws02-i for characters
before ' "'
add 3 to ws02-i
perform varying ws02-j from 256 by -1
until ws77-linha-para-parsing(ws02-j:1)
not equal spaces and "."
continue
end-perform
compute ws02-k = ws02-j - ws02-i
move "*" to reg-arquivo-entrada(7:1)
write reg-arquivo-intermediario
from reg-arquivo-entrada
if ws88-processo-verboso
display "Copybook: " reg-arquivo-entrada(ws02-i:ws02-k)
end-if
move reg-arquivo-entrada(ws02-i:ws02-k)
to ws77-arquivo-intermediario2
open input arquivo-intermediario2
if not ws88-ok
perform testar-file-status
end-if
perform until ws88-fim-arquivo
read arquivo-intermediario2
if not ws88-fim-arquivo
write reg-arquivo-intermediario
from reg-arquivo-intermediario2
end-if
end-perform
close arquivo-intermediario2
.
exibir-versao.
display "Conversor de fontes CBL2COB - alpha 0.0.2 (lançado e
- "m 06/10/2003)"
display "Copyright (C) 2003 Hudson Reis"
perform finalizar
.
exibir-ajuda.
display "Uso: cbl2cob <opcoes> <arquivo-entrada> [-o <arquiv
- "o-saida>]"
display "opções:"
display " -d <mf/mb/rm> Escolhe dialeto"
display " -h Mostra ajuda"
display " -i <arquivo-entrada> Escolhe arquivo de entrada"
display " -o <arquivo-saida> Escolhe arquivo de saida"
display " -v Modo verboso"
display " -V Mostra versão"
perform finalizar
.
copy "globals.pd".
+4
View File
@@ -0,0 +1,4 @@
fd arquivo-entrada
value of file-id is ws77-arquivo-entrada.
01 reg-arquivo-entrada pic x(256).
+5
View File
@@ -0,0 +1,5 @@
select arquivo-entrada assign to disk
organization is line sequential
access mode is sequential
file status is ws77-file-status.
+10
View File
@@ -0,0 +1,10 @@
* Arquivos de entrada e saída
77 ws77-arquivo-entrada pic x(256) value spaces.
77 ws77-arquivo-saida pic x(256) value spaces.
77 ws77-arquivo-intermediario pic x(256) value spaces.
77 ws77-arquivo-intermediario2 pic x(256) value spaces.
* Variáveis para verificar se deve mostrar ou não alguma coisa.
77 ws77-processo pic 9(001) value zeros.
88 ws88-processo-nao-verboso value 0.
88 ws88-processo-verboso value 1.
+12
View File
@@ -0,0 +1,12 @@
testar-file-status.
evaluate true
when ws88-arquivo-inexistente
display "Arquivo inexistente"
when ws88-diretorio-inexistente
display "Diretorio inexistente"
when other
display "Erro sem report: " ws77-file-status
end-evaluate
close arquivo-entrada arquivo-saida
perform finalizar
.
+33
View File
@@ -0,0 +1,33 @@
* Teste de file status.
77 ws77-file-status pic x(002) value spaces.
88 ws88-ok values are "00" "02" "04".
88 ws88-diretorio-inexistente value "05".
88 ws88-fim-arquivo value "10".
88 ws88-inexiste-registro value "22".
88 ws88-disco-cheio value "24".
88 ws88-arquivo-inexistente value "35".
88 ws88-layout-diferente value "39".
88 ws88-arquivo-ja-aberto value "41".
88 ws88-arquivo-nao-aberto values are "42" "47".
88 ws88-arquivo-bloqueado value "9A".
88 ws88-registro-bloqueado value "9D".
88 ws88-indice-corrompido values are "9$" "9)" "9(".
* Variáveis para serem usadas como contadores.
01 ws01-contadores.
02 ws02-i pic 9(003) value zeros.
02 ws02-j pic 9(003) value zeros.
02 ws02-k pic 9(003) value zeros.
02 ws02-l pic 9(003) value zeros.
02 ws02-m pic 9(003) value zeros.
02 ws02-n pic 9(003) value zeros.
02 ws02-o pic 9(003) value zeros.
02 ws02-p pic 9(003) value zeros.
02 ws02-q pic 9(003) value zeros.
02 ws02-r pic 9(003) value zeros.
02 ws02-s pic 9(003) value zeros.
* Variável para determinar se continua ou não o parsing da
* instrucao ou linha de comando.
77 ws77-parsing pic 9(001) value zeros.
88 ws88-continua-parsing value 0.
88 ws88-finaliza-parsing value 1.
+8
View File
@@ -0,0 +1,8 @@
fd arquivo-intermediario
value of file-id is ws77-arquivo-intermediario.
01 reg-arquivo-intermediario pic x(256).
fd arquivo-intermediario2
value of file-id is ws77-arquivo-intermediario2.
01 reg-arquivo-intermediario2 pic x(256).
+10
View File
@@ -0,0 +1,10 @@
select arquivo-intermediario assign to disk
organization is line sequential
access mode is sequential
file status is ws77-file-status.
select arquivo-intermediario2 assign to disk
organization is line sequential
access mode is sequential
file status is ws77-file-status.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4
View File
@@ -0,0 +1,4 @@
fd arquivo-saida
value of file-id is ws77-arquivo-saida.
01 reg-arquivo-saida pic x(256).
+5
View File
@@ -0,0 +1,5 @@
select arquivo-saida assign to disk
organization is line sequential
access mode is sequential
file status is ws77-file-status.
+222
View File
@@ -0,0 +1,222 @@
# Projeto Infocont
==================
# Legenda deste TODO file
-------------------------
#: Tópico finalizado.
o: Tópico em aberto p/ discussão.
-: Tópico em desenvolvimento.
1. Se um tópico inicial tiver o sustenido(#), ele está finalizado para mim,
Hudson, entretanto, aberto para opiniões de outras pessoas.
# cbl2cob.cob
-------------
- Estudar como fazer o parsing da linha de comando.
- Usar verbo "unstring" ou "inspect" para fazer o parsing dos verbos
com o inspect, mais trabalho de vetores, porém mais testes(embora
generalizados). Com o unstring, menos trabalho de vetores, porém
menos testes generalizados e mais código. Sugestão por ora é usar
unstring.
- Como converter um fonte?
- Como quebrar as frases?
- Unstring de uma variável indexando esta variável a uma matriz.
ex: unstring ws77-var delimited by ' '
into ws02-index(1) ws02-index(2) ws02-index(3)...
end-unstring
- O limite de indices é 65(Conforme desenvolvido pelo Daniel
Mengarda - InfoCont Sistemas Integrados Ltda).
- Como determinar o que modificar, vai ser apenas gerador, ou
vai ser conversor?
- Conversor: Converte(Modifica) frases já existentes.
- Gerador: Gera novas frases a partir de frases existentes.
- Acho que o cbl2cob terá as duas partes.
- como traduzir uma frase?
- Inspecionar a frase, para verificar se é necessário conversão
ou geração, a partir de testes condicionais(verbo inspect).
- Quebrar a frase, indexando os "pedaços" desta frase, para que
possa ser lida ao ser feito um laço de repetição.
(verbo unstring)
- aonde pegar possíveis extensões do cobol?
- qual verbo usar? inspect ou unstring, e quando?
Inspect: Inspeção de frases.
Unstring: Quebra de frases.
- há mais verbos interessantes do que estes?
Até o momento, não.
- Distribuição.
- Apenas um binário com várias bibliotecas embutidas dentro do binário.
- Verificação dos arquivos
- se existe arquivo de entrada ou não.
- se pode criar arquivo de saída ou não.
- Por último: Re-escrever o fonte.
- comentar os itens.
- otimizar os fontes, com procedures definidas.
- definir ainda. É tudo imperativo, infinitivo ou o que?
o Características do front-end.
o Verifica se há switches erradas.
o Verificação se há duplicação de arquivos(entrada e saída).
o Verificação se há arquivo de entrada.
o Pega variáveis com caminho absoluto ou caminho relativo
o Tem a característica de separar o nome do arquivo do diretório
(basename e path), sofistificação no front-end
o As variáveis podem ser em qualquer tabulação
o Tem características fixas:
cbl2cob [opcoes] [-i arquivo de entrada] [-o arquivo de saida]
o Switches de uso:
o d: dialeto.
o i: arquivo de entrada.
o o: arquivo de saida.
o v: saída verbosa.
o V: versão.
o h: ajuda.
o Prepara switches para chamar o pré-processador.
o Chama o pré-processador via call "system".
o É chamado via call "system" para que o usuário possa escolher
entre usar o pré-processador ou usar o front-end(que irá
chamá-lo do mesmo jeito).
o Há duas chamadas, uma para abrir os copybooks e outra para fechar os copy
books.
- Chama um scanner mediante o dialeto escolhido(dialeto+scanner.cob).
(ex: mfscanner.cob) (Não implementado).
- Chama um parser mediante o dialeto escolhido(dialeto+parser.cob)
(ex: mfparser.cob) (Não implementado).
# cbl2cobpp.cob
---------------
- Pré-processador para processar os fontes.
- Motivo: O verbo COPY permite que você insira um arquivo externo dentro
de um programa fonte COBOL. Então, qual seria a melhor maneira
de se converter um fonte desta maneira?
- Idéias:
Atualmente as possíveis idéias que me vieram, foram as seguintes:
- Processar os copybooks individualmente, ou seja, o usuário
os pré-processaria manualmente. Então quando o parser
encontrasse uma linha com o verbo COPY, ele iria pular essa
linha.
- Quando o parser encontrasse uma linha com o verbo COPY, ele
chamava um pré-processador, que abria o fonte, lia e o convertia.
Seria chamada uma programa que faria isso, só iria ler e
processar dados, mas seria um subprograma, então os dados
iriam ser passados via linkage.
- Seria criado um programa específico que iria criar um
novo arquivo fonte COBOL, a partir de um arquivo fonte COBOL
já existente, com algumas opções determinadas, como abertura
ou fechamento de copybooks.
Este programa seria separado e poderia ser chamado, ou via
linha de comando ou pelo programa principal, através de
uma chamada de sistema(Ou seja, os dados não seriam passados
via linkage, mas por arquivos). A medida que fosse lendo
o arquivo de entrada, ele iria gravando um arquivo de saída.
Para os copybooks pré-processados, poderiam ser criados
copybooks com o nome modificado, derivado do nome original.
Acho esta a melhor decisão.
- Poderia ser criado o programa fonte e seus copybooks, com um
sufixo semelhante ao dialeto selecionado.
ex: # fonte (arquivo de entrada e saida diferente)
teste.cbl -> entrada
teste.cob.mf -> intermediário
teste.cob -> Saida
# copybook (mesmo arquivo de entrada e saída)
header.cpy -> entrada
header.cpy.mf -> intermediario
header.cpy -> saida
- Particularidades do COPY.
- Armazenamentos
- Diretório local/remoto e/ou diretório de variável de ambiente.
- Características.
- entre aspas: COPY "workfile.cpy". (Suporta apenas este por enquanto)
- sem aspas: COPY workfile.cpy.
- sem extensão: COPY workfile.
- Pré-processamento.
- Como processar os fontes, traduzir o código sempre para minusculo ou
dar a oportunidade do usuário escolher?
- Não haverá escolha de case. O programa fonte será modificado apenas
aonde houver geração ou conversão de frases.
- Ao encontrar um verbo COPY.
- Descobrir que tipo de característica e armazenamento ele tem.
- No arquivo de saída, criar uma linha comentada, desta maneira:
(7)* Copybook <arquivo> - Abertura.
(7)* Copybook <arquivo> - Fechamento.
- Onde:
(7). Col 7.
<arquivo>. Nome do arquivo. Deve ser mantidos as características.
Nesta etapa, o objetivo é só pré-processar mesmo.
- Novos Copybooks. (Não suportado ainda, talvez não seja necessário).
- Devem ter um sufixo que diga que o arquivo é convertido, talvez
seja até interessante usar uma extensão. Ou então eles poderiam
ter o mesmo nome do copybook inicial, mas apenas com uma letra
ou item diferenciando.
# cblm2m
--------
o Conversor de case.
o Motivo: Esta rotina, poderia ser um pequeno programa apenas. Entretanto,
se um usuário quiser apenas mudar a case do seus fontes, ele teria que
re-adaptar o programa. Então achei melhor criar um pequeno programa,
com um pequeno front-end, que facilite a vida do usuário. Isso não
mudaria em nada o conversor, uma vez que eu poderia chamar o programa
via call "system" e o usuário nem notaria que isso aconteceu.
o Idéias: Estava pensando nas seguintes idéias:
o O conversor não deve mudar o valor da cláusula PROGRAM-ID ou
END-PROGRAM.
o O conversor não deve mudar os ítens entre aspas.
o Conclusão: Após ter desenvolvido o aplicativo, concluí que a melhor maneira
para se mudar a case de um arquivo seria, durante o processo de
pré-processamento, criar uma variável intermediária, e nesta variável
intermediária, mudá-la para uma case(maiúscula, por exemplo) a
a nível de testes de condição.
Se houver tempo, talvez melhore este conversor, entretanto não
será minha prioridade por agora.
# Disclaimer
o Criar disclaimer para o COBOL traduzido para o português.
o Pegar no site da FSF ou conectiva o COPIA.pt_BR(COPYING) e a licença
traduzida.
o Seguir recomendações de Jorge Godoy e usar o disclaimer e o COPYING
em inglês, devido a FSF não ter direitos legais no Brasil.
# Padronização
# Identification division.
o Não vou colocar date-compiled, installation e security pois não vejo
necessidade. Seria interessante o uso do remarks, porém ele não faz
parte do COBOL 85. Então irei colocar um comentário sobre isso depois
do date-written.
o Achei viável a criação do nome cob2tc. Pensei primeiro em mf2tc, mas
achei melhor generalizar, pois assim poderíamos criar uma switch para
determinar qual tipo de dialeto será o arquivo de entrada. (t=[ARG]).
Depois pensei em cob2tc, o COB seria para o fonte COBOL de qualquer
dialeto e o TC, seria para o TC. Inicialmente soa como se fosse só
do TC, mas como o TC seguiria os standards, provavelmente não haveria
problema em colocá-lo. Também poderiámos colocar o nome como cbl2cob,
pois assim seria bem genérico. O CBL representaria o fonte COBOL em
diversos dialetos e o COB representaria o fonte COBOL regido pelo
standard. Entretanto isso seria apenas para colocar um nome intuitivo,
mas o usuário poderá colocar o fonte com qualquer extensão. Acho melhor
o cbl2cob.
o O fonte será desenvolvido em formato fixo, pois quero que ele fique
bem intuitivo. Então, irei usar comentários fixos (*) na coluna 7
e comentários inline(*>) nas colunas posteriores a coluna 7. Será
necessário então o uso da switch "-F" ao compilá-lo.
# File section.
o O tamanho do registro será de 256 posições. Estou seguindo como
base a partir do gscreen e do scanner do TC(scan.c). Ou seria melhor
colocar isso como uma switch do conversor? (s=[ARG]). Não concordo
com a criação de uma switch, pois isso acarretaria a criação de uma
série de perform's para fazer a leitura byte a byte do registro e
poderia aumentar o tempo de conversão.
# Prefixo para variáveis.
o Prefixo inicial,
o ws: working-storage section.
o ss: screen section.
o ls: linkage section.
o Prefixo adicional,
o Nivel da variável.
o Nivel da variável,
o Consecutivo: 01, 02, 03...
# Verbos.
o Indentação de 3 posicoes no perform.
o Indentação de 4(ou 2) posicoes no evaluate.
o Indentacao de 6 posicoes no when.
o Indentacao de 2 posicoes no if.