replace with something else
optional, replace with something else
A. Luck Source Files * General Info * File Format B. Data Types * General Info * Strings * Numbers * Decimals C. Subroutines * Procedures * Functions D. Standard Orders & Blocks * Comment ">>" * Convert Data Types "convert" * Delay "delay" * End Current Block "end" * Hear Input "hear" * Hear Program Argument "heararg" * If Block "if:" * Infinite Loop Block "infinite:" * Loop Block "loop:" * New Variable "new" * Random Number "random" * Return Value "return" * Say "say" * Say Without New Line "saysolo" * String I/O Read "sio_read" * String I/O Write "sio_write" * Quit Program "quit" E. Native Code Support * General Info * Native Language "@lang" * Native Code at Beginning "@<" * Native Code "@@" F. Other * Assignment Operator "=" * Bracket Operator "[ ]"
Luck source files hold the code that will compile into an application. Luck source files should have the extension "LUK". LUK files are ASCII text files with 7-bit encoding. Luck is case-sensitive. For example, 'foo' and 'FOO' are different names.
luck: program_name proc: main starting_code end other_procedures_and_functions
Variables must be created with the 'new' order before they can be used elsewhere. Also, variables can only be used in the procedure that they are created in. Note that variables are initialized to 0 when they are created.
Strings are groups of characters (letters, numbers, symbols, etc.). They can be used in two ways. One way is to enclose a group of characters with quotation marks, creating a unit called a literal string:
"My name is not John Doe!"
Another way is to use a variable. String variables are preceded by a "$" at all times:
Numbers cannot have decimal points. They can be used in two ways. One way is to create a number literal:
Another way is to use a variable. Number variables are preceded by a "#" at all times:
Decimals are numbers that have decimal points. They can be used in two ways. One way is to create a decimal literal:
Another way is to use a variable. Decimal variables are preceded by a "&" at all times:
Procedures are code blocks that can be called by a program to perform a set of instructions. They do not return a value. Procedures allow two optional arguments.
proc: procedure_name argument(s) code end
Functions are code blocks that can be called by a program to perform a set of instructions. They return a value to the program. Functions allow two optional arguments. If the function return is placed within an 'if:' or 'loop:' block, there must be another return outside of all blocks.
func: data_type_and_function_name argument(s) code return value_to_return end
The comment order renders everything after it invisible to the program.
Takes the value in the source variable, and puts it in the destination variable (data type is converted). Note that the source and destination variables must be of different data types.
convert source_variable to destination_variable
The delay order creates a delay for the number of seconds specified.
The end order specifies the end of a function, procedure, or if block.
The hear order reads input from the user into a variable.
The heararg order reads the program's command line argument to the specified variable. Note that this may only be used in the 'main' procedure.
The if block determines if the expression is true, if it is, the code within the block is executed. The comparison operator can be "=", ">", "<", ">=", or "<=".
if: variable_or_number_literal comparison_operator variable_or_number_literal code end
The infinite loop block is identical to a 'loop:' block, except that it reapeats indefinitely. The only way to end an 'infinite:' block is to use the 'quit' order.
infinite: code quit end
The loop block determines if the expression is true, if it is, the code within the block is executed. Then, the process begins again. The process will continue until the expression is no longer true. The comparison operator can be "=", ">", "<", ">=", or "<=".
loop: variable_or_number_literal comparison_operator variable_or_number_literal code end
The new order creates a new variable. Note that the variable must be created with this order before it can be used elsewhere. Also, the variable can optionally be assigned a value.
new variable = expression_or_function_call
The random order puts a random number from 0 to 9 into the specified variable.
The return order returns the specified variable to the program from a function.
Prints the specified string to the output with a new line. Note that the last use of 'say' or 'saysolo' in a program must be 'say'. Using 'say' without an argument causes a blank line to be printed.
Prints the specified string to the output without a new line.Note that the last use of 'say' or 'saysolo' in a program must be 'say'.
The sio_read order reads a specified file into a string.
sio_read (file)_string_literal_or_variable to string_variable
The sio_write order writes a string into a specified file.
sio_write (file)_string_literal_or_variable from string_variable
The quit order ends the program prematurely.
Luck supports the ability to use features from a more established language that Luck does not have. Currently, Luck only supports native code from Java 1.0.2.
The native language order specifies the language and version number of the following native code.
@lang native_language native_language_version
The native code at beginning order inserts native code at the beginning of the generated file.
The native code order inserts native code in the generated file.
The assignment operator assigns the value after the equals sign to the variable before the equals sign. Note that when a mathematical expression is after the equals sign, there must be spaces between every symbol or variable.
variable = expression
variable = [return_type_and_function_name argument(s)]
The bracket operator executes the procedure or function within it. Also, the arguments, if there are any, are placed after the subroutine name but before the end of the operator.
variable = [return_type_and_function_name argument(s)]