Skip to content

Commit

Permalink
Vaxscan (#4049)
Browse files Browse the repository at this point in the history
* Adding vaxscan ANTLR4 parser

* Update README.md

* Adding desc.xml file and changed alt to alt_ to avoid conflicts.

* Remove the spurious lexer rules for some of the string literals.

* Grammar reformatted using antlr-format tool.

* Adding pom.xml file for maven

---------

Co-authored-by: William Cox <bill@dev-ubuntu-vm>
  • Loading branch information
whcox603 and William Cox committed May 11, 2024
1 parent 4fbb789 commit d5c2009
Show file tree
Hide file tree
Showing 25 changed files with 4,637 additions and 0 deletions.
49 changes: 49 additions & 0 deletions vaxscan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
This is the grammar for VAX SCAN. The following description is lifted from the
Guide to VAX SCAN (Copyright ©1985, 1986, 1989 by Digital Equipment
Corporation).

"VAX SCAN is a block-structured programming language in the
VAX/VMS environment that is designed to build tools to manipulate
text strings and text files. The primary applications for VAX SCAN are
filters, translators, extractors/analyzers, and preprocessors."

Digital Equipment (DEC) having decided not to continue the product or port
it to their new hardware platforms (ALPHA and Itanium) made the source
code FREEWARE.

This ANTLR4 grammar is based on the BNF provided in the source code.

The following copyright statement is used throughout the source code. As they
copied the source directory tree and provided it AS-IS I would assume this no
longer applies.

********************************************************
COPYRIGHT 1989, 1996
DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE
AND WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR
OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.

THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY
DIGITAL EQUIPMENT CORPORATION.

DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY
DIGITAL.

*********************************************************

The source code along with VAX/VMS binaries are available on the VMS Software
Inc (VSI) website under Freeware.

https://vmssoftware.com/community/freeware/

The source code is a mix of Bliss, PLI, and Macro Assembler. The compiler uses
a code generator (VAX Code Generator) that will create VAX/VMS object files.
Bliss is a family of compilers across several DEC platforms. It was designed as
a systems implementation language.

Under the examples directory are a number of small sample programs that were
provided with the software kit. They all parse cleanly.


6 changes: 6 additions & 0 deletions vaxscan/desc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<desc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../_scripts/desc.xsd">
<antlr-version>^4.10</antlr-version>
<targets>Antlr4ng;CSharp;Cpp;Dart;Go;Java;JavaScript;PHP;Python3;TypeScript</targets>
<inputs>examples</inputs>
</desc>
93 changes: 93 additions & 0 deletions vaxscan/examples/caps.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
!
! COPYRIGHT (c) 1989 BY
! DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
!
! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
! ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE
! INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER
! COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
! OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY
! TRANSFERRED.
!
! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE
! AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
! CORPORATION.
!
! DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
!

MODULE process_basic_identifiers;

!+
! This SCAN program will transform a BASIC program
! printing all the BASIC keyword in upper case and
! printing all the identifiers in lower case
!-

SET alpha ( 'a'..'z' OR 'A'..'Z' );
SET other ( alpha OR '0'..'9' OR '$' OR '_' OR '.' OR '%' );

TOKEN id { alpha [ other ]... };

DECLARE keyword: TREE( string ) OF INTEGER;

MACRO match_id TRIGGER { id_text: id };

IF EXISTS( keyword( UPPER( id_text ) ))
THEN
ANSWER UPPER( id_text );
ELSE
ANSWER LOWER( id_text );
END IF;

END MACRO;

PROCEDURE process_ids MAIN;

!+
! This is a representative list of BASIC keywords.
! You can add more if you desire.
!-

keyword( 'TYPE' ) = 0;
keyword( 'EXPLICIT' ) = 0;
keyword( 'DECLARE' ) = 0;
keyword( 'INTEGER' ) = 0;
keyword( 'CONSTANT' ) = 0;
keyword( 'STRING' ) = 0;
keyword( 'EDIT$' ) = 0;
keyword( 'ON' ) = 0;
keyword( 'ERROR' ) = 0;
keyword( 'GOTO' ) = 0;
keyword( 'OPEN' ) = 0;
keyword( 'FOR' ) = 0;
keyword( 'INPUT' ) = 0;
keyword( 'AS' ) = 0;
keyword( 'OUTPUT' ) = 0;
keyword( 'NOMARGIN' ) = 0;
keyword( 'WHILE' ) = 0;
keyword( 'LINPUT' ) = 0;
keyword( 'OR' ) = 0;
keyword( 'POS' ) = 0;
keyword( 'LEFT$' ) = 0;
keyword( 'RIGHT$' ) = 0;
keyword( 'SEG$' ) = 0;
keyword( 'LEN' ) = 0;
keyword( 'END' ) = 0;
keyword( 'NEXT' ) = 0;
keyword( 'PRINT' ) = 0;
keyword( 'CLOSE' ) = 0;
keyword( 'RESUME' ) = 0;
keyword( 'OPTION' ) = 0;
keyword( 'IF' ) = 0;
keyword( 'THEN' ) = 0;
keyword( 'ELSE' ) = 0;

START SCAN
INPUT FILE 'caps.bas'
OUTPUT FILE 'new_caps.bas';

END PROCEDURE;

END MODULE;
33 changes: 33 additions & 0 deletions vaxscan/examples/comment.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
MODULE recognize_comment;

!+
! This module recognizes PL/I or C style comments of the form:
!
! /* anything_but_star_slash... */
!-

SET NON_star ( NOT '*' );
SET NON_star_or_slash ( NOT ( '*' OR '/' ) );

TOKEN comment { '/*'
[ NON_star | '*'... NON_star_or_slash ]...
'*'... '/' };

MACRO do_comment TRIGGER { r : comment};
WRITE 'The comment is: ', r;
END MACRO;

PROCEDURE main_routine MAIN ( );

!+
! Specify the DATA STACK clause so we can recognize longer comments,
! since they can span multiple lines.
!-

START SCAN
DATA STACK 4096
OUTPUT FILE 'NL:';

END PROCEDURE;

END MODULE;
26 changes: 26 additions & 0 deletions vaxscan/examples/compress.scn
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module compress_blanks;

!+
! This SCAN program will read the file bound to the logical name
! SCN$INPUT. One or more tabs or spaces found in the file will
! be compressed to a single space. The result of the translation
! is placed in the file bound to the logical name SCN$OUTPUT.
!-

token blanks { { ' ' | s'ht' }... };

macro compress trigger { blanks };

answer ' ';

end macro;

procedure main main;

start scan
input file 'scn$input'
output file 'scn$output';

end procedure;

end module;

0 comments on commit d5c2009

Please sign in to comment.