SYCPOL

SYCPOL (System card programming language, pronounced /'sɪkpɔl/) is a mildly esoteric programming language created by User:Fergusq in 2014 inspired by COBOL. The program is a set of system cards which are interpreted by a "system card machine".

Terminology
A system card machine (sometimes called a system card interpreter machine, SCIM /'ʃkɪm/) is a machine that reads system cards and interprets the code. A SCIM that interprets SYCPOL is called a SYCPOL-SCIM. A SCIM emulator is called a VISCIM /'vɪʃ.kɪm/, virtual SCIM.

Word file in this article means a physical file or envelope which contains cards. That's why VISCIMs usually call directories files.

System cards
For some reason, all system card machines only accept one type of cards, The Standard System Card I (SSC-M1). The M1 card is a sized 22x22.

The first line is either  or. It is important that there are spaces between words, see below for an example. The second line is always. This is called a card declaration. After it there are 20 lines of other code.

Hardware and devices
As SCIMs are multi-purpose devices there is no standard hardware. When used in offices, a SCIM-computer usually has a printer, an input card reader and a program card reader. Sometimes there is also a keyboard.

Computer architecture
Because SCIMs are used to interpret code only from system cards, manufacturers don't usually release too much documentation about the architecture or machine language.

Extensions and compatibility
All manufacturers usually provide full compatibility with standard SYCPOL. Extensions contain instructions used to command specific devices, perform scientific calculations, etc.

Strings

 * – A 8 characters long string.

Integers

 * – A byte.
 * – Two bytes.

Streams

 * – Super type of all streams.
 * – Output only.
 * – Input only.
 * – Both.

Lists
Prefixed with. Example:  is a list of integers and   is a list of lists of strings.

Structures
Structures are programmer-defined data types prefixed with  and declared in the.

The structure of the program
The program is split to various divisions, which contain information about the program. The  contains the name of the program and the author. The  contains a list of external procedures and variables. The  contains a list of open I/O streams, files etc. The   contains all constants and static variables. The  contains all procedures.

Divisions contain declarations. They can be for example constants, variables or procedures.

Sections are parts of declarations. The most declarations contain only one section, but some, like procedures, contain many.

DOCUMENTATION DIVISION
This division starts a module and cannot begin in the middle of a card. Following declarations are supported:


 * – The name of the module.
 * – The name of the author.
 * – General information about the module.

IMPORTS DIVISION
Following declarations are supported:


 * – An external procedure.  is an identifier. Contains following subdeclarations:
 * – The name of the procedure.
 * – The name of the module.


 * – An external structure.  is an identifier. Contains following subdeclarations:
 * – The name of the structure.
 * – The name of the module.

INPUT OUTPUT DIVISION
Following declarations are supported:


 * /  – Opens or closes a stream.   is either   or.
 * /  /   – Declares a new stream.   is an identifier. Contains following subdeclarations:
 * – Declares the output part of a stream.  is the name of the device.
 * – Declares the output part to the standard output.
 * – Declares the input part of a stream.  is the name of the device.
 * – Declares the input part to the standard input.

LAYOUT DIVISION
Following declarations are supported:


 * – Declares a new structure. Supports following sections:
 * – The name of the structure for exporting.
 * – The author name. Optional.
 * – Information about the structure. Optional.
 * – The default section. Doesn't have to specified if is the only one.
 * – Declares a field. NAME can't be any of following:
 * – Declares a field. NAME can't be any of following:

STORAGE DIVISION
Following declarations are supported:


 * – Declares a new constant.
 * – Declares a new global variable.

PROGRAM CODE DIVISION
Following declarations are supported:


 * – Declares the main procedure.
 * – Declares a procedure. Following sections are supported:
 * – The default section. Doesn't have to be specified if starts the procedure.
 * – The name of the procedure for exporting. Optional.
 * – The author name. Optional.
 * – Information about the procedure. Optional.
 * – Declares all parameters. Following subdeclarations are supported:
 * – Declares a new mutable parameter.
 * – Declares a new immutable parameters.
 * – Declares all variables. Following subdeclarations are supported:
 * – Declares a new variable.
 * – Declares the procedure code.

Imperative code
and  contain imperative program code. For example, from the hello world below:

STANDARD SYCPOL supports following statements:


 * – Assigns a variable a new value. Requires following arguments:
 * – The new value.  is an expression.
 * – Increments a variable.
 * – Decrements.


 * – Assigns a new value to a field.  is the name of the field. Requires:
 * – The structure.
 * – The new value.


 * – Adds a value to the end of a list. Requires:
 * – The list.


 * – Remove a value from the end of a list. Requires:
 * – The list.


 * – Sends a value to a stream. Requires:
 * – The stream.


 * – Conditional jump.
 * – Jump.


 * – Proceeds to a procedure.
 * – The procedure.
 * – Arguments, a list of values separated by newlines. See examples.


 * – Ends the procedure. Requires one of:
 * – Exits from the procedure normally.
 * – Terminates the program.

And following expressions:


 * – Reads a value from a stream. Requires:
 * – The stream.


 * – The length of a string. Requires:
 * – The string.


 * – Character at.
 * – The position.
 * – The string.


 * – Reads from a list.
 * – The position.
 * – The list.


 * – The first element of a list.
 * – The list.


 * – The last element of a list.
 * – The list.


 * – Reads a field from a structure. Replace  with the name of the field.
 * – The structure.

TODO more.

Simple declarations
A simple declaration has form

where TYPE is a datatype listed in SYCPOL section.

STRING N declarations
A string value is surrounded by -characters. Escape character is  too.

INTEGER N declarations
An integer value is a sequence of number characters.

STREAM declarations
These declarations may only occur in the INPUT OUTPUT DIVISION.

The standard declares only two valid : for input and  for output.

An input+output stream has both  and. Input only stream has only  and output only has only.

VISCIMs may allow  (file system) devices:

Procedures
Procedures are used to perform various tasks in SYCPOL. While they can't return values as in many other languages, all parameters are passed by reference so that they can be modified.

The MAIN PROCEDURE is in many ways more limited that other procedures. It can't have local variables and can't be called from the program.

Structures
An example structure, PERSON:

An example constructor procedure, CREATE:

And how these two are used:

Character set
The character set is not specified, but the standard enforces support for following characters:
 * – Uppercase letters
 * – Numerals
 * – A selection of the most useful special characters, mostly for string literals.
 * Empty space – This is obvious. Note that a special "newline" character is not required, it is automatically inserted by the printer after printing 22 other characters.

It recommended for system card and machine manufacturers to NOT include support for other letters, as that would break compatibility. Anyway, why would someone use other card than SSC-M1? The Standard System Card I supports all these characters and is certainly the best choice for all.

Newlines
At the third line of a card, there should be a newline if the card is continuation to the previous card. As only the DOCUMENTATION DIVISION may start a new module, only it can be at the third line.

After a single-section declaration is a newline. For example, the next line after a constant contains the value and the second next the newline.

Indentation rules
Prepositions starts a new indentation layer. If a statement is continued to the next lines, they are in a new indentation layer.

Example, (c) means "there is an indentation layer because the statement continued to this line" and (p) "a prepositons introduced this layer".

RS-SYCPOL
RS-SYCPOL was designed to make storing and using cards easier, allowing cards to be in any order. In RS things can be declared again, with more information. It also supports MODULE-declarations. See examples.

Changes compared to the standard

 * All divisions, declarations and sections can be respecified.
 * LAYOUT DIVISION, PROGRAM CODE DIVISION or PROCEDURE CODE SECTION are not required to be specified, if it would appear at the top of a card.
 * A MODULE declaration may appear immediately after the CARD declaration.

VISCIM-JA
VISCIM-JA (Virtual system card interpreter machine in Java, /'vɪʃ.kɪm.jɑ/) is a VISCIM by fergusq. Although not strictly compatible with RS-SYCPOL, it shares many same formatting rules and other constructs. The SYCPOL dialect of this SCIM is called VISCIM-JA-SYCPOL. See external resources for downloads.

Indentation rules
If a statement continues to the next line, the continuation should be on the next indentation layer. No other indentation is required.

MODULE declaration
As in RS-SYCPOL, there is an optional MODULE declaration. While it should be used at the top of a card, VISCIM-JA allows it to occur at the middle of a card.

Multiple declarations
Allowing cards to be supplied in any order, modules, divisions, procedures, structures, sections and all other kind of declarations may be declared multiple times. The new declaration doesn't replace the old but complements it.

The DOCUMENTATION DIVISION cannot be respecified as in RS-SYCPOL.

It is not required to specify LAYOUT DIVISION, PROGRAM CODE DIVISION or PROCEDURE CODE SECTION, if it would appear at the top of a card.

Fibonacci sequence
Fibonacci sequence in RS-SYCPOL.

External resources

 * VISCIM-JA – The first known implementation.