Handwritten Text Recognition for manuscripts and early printed texts
ALPHA Script - Keywords and Symbols
1. Keywords & Symbols (Draft 17)
ALPHA Script common keywords among the most well known programming languages
categorized based on programming logic.
Boolean
1. AND – Logical "and"
2. NOT – Logical "not"
3. OR – Logical "or"
4. XOR Logical "xor"
5. TRUE Logical "true"
6. FALSE Logical "false"
Bit
1. SHIFT – Bit shift
Mathematics
1. NULL Non existent value
Control
1. IF Check if a condition is true
2. ELSE Check if a condition is otherwise
3. WHILE Loop until a condition is true
4. BREAK Break the while loop
5. CONTINUE Jump a loop and continue to the next
6. TRY Error inspection block
7. CATCH Error handling block
8. EXIT Immediate exit from the program
Results
1. RETURN Return a result from a function
2. ALPHA Script specific keywords categorized based on programming logic.
Declarations
1. ALIAS Create ALPHA Script commands aliases
2. DIRECTIVE Specify options for the target language
3. VAR Declare a variables
4. ARRAY Declare an array of variables
Structure
1. PACKAGE Encapsulate the program under a package
2. USE Use an existing package for a program
3. BEGIN Begin of a code segment
4. END End of a code segment
Control
1. INPUT Input data from a source
2. OUTPUT Output data to a target
3. SET Set a value to a variable or an array element
4. CALL Call a function or a class method
5. LOOP Loop for specified iterations
6. COUNTER Iterations counter
Class
1. CLASS Create a new class
Function
1. FUNCTION Create a new function
Method
1. METHOD Create a new method
Errors & Exceptions
1. DEBUG Log errors and exceptions
3. Utilities
1. DB Database connections, SQL and ORM
2. NET Network connections and communication
3. FILE Open, write, append and delete files
4. SECURITY Security, encryption and decryption
5. GRAPHICS Graphics interface
6. SOUND Sound interface
7. SYSTEM System interface
8. VIRTUAL Virtual interface
Show
1. PRINT Print anything to an output device
6. ALPHA Script keywords explanation. Please note that ALPHA Script is "case insensitive" but
the prototype defines the keywords in capital letters without being restrictive.
AND, NOT, OR, XOR
These are simple operands that can only exist in the middle of two phrases.
TRUE, FALSE
These are simple representations of logical "true" and logical "false" and can be
used in any condition.
SHIFT
This operand is only for bit operations.
NULL
This operand symbolizes the empty space and it can be used in any expression.
IF, ELSE
These keywords – also known as the "IF – ELSE" blocks are used to check if a
condition is valid or not. Keyword "ELSE" can only be used in conjunction with
keyword "IF".
WHILE, BREAK, CONTINUE
These keywords are used to loop under a condition, to break the loop and jump to a
next iteration of the loop. Keyword "WHILE" must always be followed by a
condition. Keywords "BREAK" and "CONTINUE" can be used in conjunction with "IF
ELSE" blocks.
TRY, CATCH
These keywords – also known as the "TRY – CATCH" blocks are used to inspect if
an exception or an error was raised during the execution inside the "TRY" block
and then passes the program flow to the "CATCH" block where the programmer can
handle the problem in various ways.
EXIT
This keyword exits the program and stops any further operations. Optionally, it
can report an exit code which is defined by the programmer. The exit code can be a
number or any UTF8 string.
RETURN
This keyword returns a result from a function. It can only be used in the body of
a "FUNCTION" and it may return any number or any string or "NULL".
7. ALIAS
This keyword is an innovation of ALPHA Script. With keyword "ALIAS" the programmer
can generate aliases of ALPHA Script keywords and use them in the program. This is
to support programmers with different programming skills and styles and to let
them remap the available dictionary the way they like.
DIRECTIVE
This keyword is very important for declaring to the converters the "nature" of the
program. For example if the program is supposed to be using threads then the
programmer has to choose an appropriate predefined directive or explicitly define
the programming language in which ALPHA Script must be converted for better
results. ALPHA Script does not support many of the features of the programming
languages – and should not because it is an abstract metalanguage and therefore
this mechanism is essential.
VAR
This keyword declares a new variable of an abstract type which has a "NULL" value.
ALPHA Script is typeless and any variable is actually an object. Every new
variable inherits a set of useful abstract methods that have an impact on the data
they store. Finally, "VAR" declares two types of variables in the program,
"GLOBAL" and "LOCAL" which have a global scope and a local scope respectively and
two types of variables in a class, "PUBLIC" and "PRIVATE" which have a public
scope and a private scope respectively.
ARRAY
This keyword declares a new array of variables. Each element corresponds to an
abstract type, an object, which has a "NULL" value and is typeless. As with "VAR",
"ARRAY" elements inherit a set of useful abstract methods that have an impact on
the data they store. Finally, "ARRAY" like "VAR", declares "GLOBAL" and "LOCAL"
variables in the program or "PUBLIC" and "PRIVATE" in a class.
PACKAGE
This keyword encapsulates an ALPHA Script program in a package. Many packages,
much like units, can be used in order to separate and divide a big ALPHA Script
program into smaller modules.
USE
This keyword imports and uses a preexisting package.
BEGIN, END
These keywords – also known as the "BEGIN – END" blocks – are used to set the
entry point and the exit point of a code segment respectively. These keywords can
be used inside an "IF – ELSE" block, a "WHILE", a "TRY – CATCH" block, a "LOOP",
a "FUNCTION" body, a "METHOD" body and a "CLASS" body.
8. INPUT, OUTPUT
These keywords get data from a source and send data to a source respectively.
Keywords "INPUT" and "OUTPUT" are abstract representations of any I/O in any
programming language. Finally, "INPUT" and "OUTPUT" can represent any device such
as a keyboard and a screen and for this purpose there are a set of predefined
options to use with.
SET
This keyword sets a value to a "VAR" or to an "ARRAY" element.
CALL
This keyword calls a function or a class method by its name passing any arguments
and stores the result to a "VAR" or to an "ARRAY".
LOOP, COUNTER
These keywords are combined to loop for a specified number of iterations.
Optionally, a positive or negative step may be used with the "LOOP" keyword.
Keyword "COUNTER" automatically increases for each iteration. The default value of
"COUNTER" is zero.
CLASS
This keyword declares a class. The class may be either dynamic or static.
FUNCTION
This keyword declares and defines a new function. The name of the function can be
any string that starts with a letter and contains numbers and symbols with a few
exceptions. The parameters must be enclosed in parentheses. A function must always
return a value so "FUNCTION" is always used in conjunction with the "RETURN"
keyword.
METHOD
This keyword declares and defines a new class method. The name of the method can
be any string that starts with a letter and contains numbers and symbols with a
few exceptions. The parameters must be enclosed in parentheses. A method must
always exist in a class and may or may not return a value.
DEBUG
This keyword is used when a programmer wants to log errors and exceptions. This
keyword can be used anywhere in the program and may be converted with many
different meanings among programming languages. For example in .NET languages this
might be converted as the command that prints the errors and the exceptions in the
console.
9. DB
This keyword is used to connect to a database, to execute queries and to map
database tables as objects. Keyword "DB" can convert database tables with their
data into an ORM that can be represented as a multidimensional "ARRAY" which is
like ordered maps in PHP.
NET
This keyword is used to enable network connectivity and communication with the
Internet. Keyword "NET" is an abstraction of any network communication protocol.
FILE
This keyword is used to open, read, write, append and delete files. Keyword "FILE"
is an abstraction of any file in any file system.
SECURITY
This keyword is used to enable security mechanisms, encryption and decryption.
Keyword "SECURITY" is an abstraction of any security protocol.
GRAPHICS
This keyword is used to interface with the graphics subsystem. Keyword "GRAPHICS"
is an abstraction of any graphics card.
SOUND
This keyword is used to interface with the sound subsystem. Keyword "SOUND" is an
abstraction of any sound card.
SYSTEM
This keyword is used to get or set system parameters and to execute applications.
Keyword "SYSTEM" is an abstraction of any computer system.
VIRTUAL
This keyword enables the programmer to map virtual functions on virtual
interfaces. Keyword "VIRTUAL" is an abstraction of any software or hardware.
PRINT
This keyword is used to print anything in the specified output device. The
programmer can choose among a set of predefined outputs.
10. ALPHA Script keywords syntax.
AND, NOT, OR, XOR
expression [AND / NOT / OR / XOR] expression
TRUE, FALSE
expression [= ! < >] [TRUE / FALSE]
SHIFT
SHIFT:[LEFT] / [RIGHT] [number]
NULL
…NULL…
IF, ELSE
IF expression
BEGIN
…
END
ELSE
BEGIN
…
END
WHILE, BREAK, CONTINUE
WHILE expression
BEGIN
IF expression
BEGIN
BREAK
END
ELSE
BEGIN
CONTINUE
END
END
11. TRY, CATCH
TRY
BEGIN
…
END
CATCH
BEGIN
…
END
EXIT
EXIT {[number] / ['string' or "string"]}
RETURN
RETURN NULL / [number] / ['string' or "string"]
ALIAS
ALIAS [ALPHA Script keyword] [New keyword name]
DIRECTIVE
DIRECTIVE [Any predefined directive] / [Any target language name]
Predefined directives
1. GENERAL
2. AVERAGE
3. SPEED
4. SPACE
5. THREADS
Target language names examples (The list may contain any programming language)
1. Ada
2. C
3. PHP
4. VB.NET
5. Python
VAR
1. VAR:[GLOBAL] / [LOCAL] [Variable name]
2. VAR:[PUBLIC] / [PRIVATE] [Variable name]
ARRAY
1. ARRAY:[GLOBAL] / [LOCAL] [Array name]
2. ARRAY:[PUBLIC] / [PRIVATE] [Array name]
12. VAR, ARRAY - Inherited Functions
1. [Variable name] / [Array name]{[index]}.[Inherited function]
2. [Class name].[Variable name] / [Array name]{[index]}.[Inherited function]
Inherited functions
1. REVERSE – Reverses a string or a number
Returns: [string] / NULL
2. EXPLODE – Breaks a string into an array (Only for "VAR")
Returns: ARRAY / NULL
3. IMPLODE – Returns a string from an array (Only for "ARRAY")
Returns: [string] / NULL
4. SORT:ASC / DESC – Returns a sorted array (Only for "ARRAY")
Returns: [A sorted ARRAY] / FALSE
5. INSERT [value] – Returns a new array (Only for "ARRAY")
Returns: [A new ARRAY] / FALSE
6. REMOVE:INDEX [index] / VALUE [value] – Returns a new array
(Only for "ARRAY")
Returns: [A new ARRAY] / FALSE
7. CLEAR – Returns a null array (Only for "ARRAY")
Returns: [A null ARRAY] / FALSE
8. TRIM:LEFT / RIGHT / BOTH – Strips white spaces
Returns: [string] / NULL
9. LEN – Returns the length of a string or "ARRAY" elements
Returns: [number] / NULL
10. SUBSTR [start] [end] – Returns a substring
Returns: [string] / NULL
11. FIND [string] – Finds a string and returns its position
Returns: [number] / FALSE
12. REPLACE [Existing string] [New string] – Replaces a string
Returns: TRUE / FALSE
13. ASCII [char] – Converts a character into an ASCII value
Returns: [number] / FALSE
PACKAGE
PACKAGE [name]
USE
USE [name]
BEGIN, END
BEGIN
…
END
13. INPUT, OUTPUT
INPUT / OUTPUT:[Any predefined I/O] [value] / [variable]
Predefined inputs
1. KEYBOARD
2. MOUSE
3. GAMEPAD
4. MICROPHONE
5. CAMERA
6. FLOPPY
7. ODD
8. HDD
Predefined outputs
1. SCREEN
2. PRINTER
3. SPEAKERS
4. CONSOLE
5. FLOPPY
6. ODD
7. HDD
SET
1. SET [VAR] / [ARRAY[index]] [value]
2. SET [Class name].[VAR] / [ARRAY[index]] [value] – Only for [PUBLIC] scope
CALL
1. CALL [Function name] {[(arg_1, arg_2,…)]} [VAR] / [ARRAY]
2. CALL [Class name].[Method name] {[(arg_1, arg_2,…)]} [VAR] / [ARRAY]
LOOP, COUNTER
LOOP [number] {[+ / ] [step]}
BEGIN
…
END
COUNTER – Auto increment counter for each iteration (Use it to get iterations)
CLASS
CLASS:[DYNAMIC] / [STATIC] [name]
BEGIN
…
END
FUNCTION
FUNCTION [name] {[(arg_1, arg_2,…)]}
BEGIN
…
RETURN [value] / NULL
END