Specification Files

From FizzFuzz

Jump to: navigation, search

In FizzFuzz, specification files are used to tell the FizzFuzz compiler how to handle variables and other such things. This is because FizzFuzz is unique in the way it deals with variables. The compiler actually contains no information on the variables objects being used by any given FizzFuzz script. Specification files (or spec files, as they are also referred to) are included in a program via the #spec directive in FizzFuzz.

Contents

Comments

Comments are placed in a FizzFuzz spec file by putting a hash symbol (#) at the start of a line. It must be placed at the start of a line, or else there will be a syntax error in the spec file.

# This is a FizzFuzz specification file comment.

Forced Inclusion

Specification files may also be set to forcefully include a FizzFuzz script. This could be useful in serving the purpose of having a FizzFuzz object that interacts closely with a variable extension to the library. This is done by placing the @ symbol at the beginning of a line. Everything after that character on the line is considered the file path, so there is no need for quotes or anything of the sort.

# This forces "Example.ffp" to be included in any project including the current file.
@ "Example.ffp"

Defining Variable Data

To define the actual variable data, the name of the variable, as it will be used by the compiler must be written out on the front of a line, followed by beginning and ending braces. Within these braces can be several attributes used to modify the variable. There are several valid attributes for variable types, and they are described in detail in the following paragraphs. All attributes are seperated by placing a semicolon at the end of it, and the values of the attributes are assigned by placing the attribute equal to a group of values in parantheses, seperated by commas. That format would be (The linebreaks are for seperation purposes. These can be organized any way):

variable
{
	attribute = (value_1, value_2, etc);
	attribute2 = (value_1, value_2, etc);
	attribute3;
}

Function Attribute

The first and, most likely, common attribute is the functions attribute. The valid values for this attribute are valid function names. Placing an ellpisis as one of the values will set the compiler to allow any value as a valid function name. If *reference is placed as a value, functions from the associated FizzFuzz object will be valid function names.

# This allows the functions length(), concatenate(), copy(), get_character(), truncate(), ascii2base(), and base2ascii() for the
# string variable type.
string
{
	functions = (length, concatenate, copy, get_character, truncate, ascii2base, base2ascii);
}

Variable Attribute

The second attribute is the variables attribute. These are valid variables used when referring to the variable-type. These can be comprised of any valid variable name. If an ellipsis is placed as a value, then any valid variable name will be allowed by the compiler. If *reference is included as a value, then only variables of the associated FizzFuzz object will be allowed by the compiler.

# This gives the string object the variable length.
string
{
	variables = (length);
}
# This sets it so that any function or variable of the associated object is a valid function for this variable type.
object
{
	functions = (*reference);
	variables = (*reference);
}
# This indicates that any name for misc are valid variables, and all functions aside from New (which can be overwritten) are
# valid functions names for ext_object.
misc
{
	functions = (New, ...);
	variables = (...);
}

The read_in attribute is used to set the values that are legally assignable to the variable type. By default, all values (strings, numbers, and object) are allowed. The sequences *string, *numeric, and *object are used to individually allow strings (anything in quotes), numbers, and objects. If any literal is included in these, they will be allowed, but they can only be alphameric literals. Like this, a series of the included literals would be allowed. If a literal is prepended with a tilde (~) then that literal is forced to be solitary when it is assigned to this variable value. This means that only this literal can be assigned, and no other characters can be attached. If an exclamation point (!) is placed in front of a literal, that means that the literal is not allowed. This can be combined with sequences (*string, *numeric, and *object) and a tilde with no problem.

# The *number value for the read_in attribute indicates that only numeric fields are valid for being assigned to this field. 
integer
{
	read_in = (*numeric);
}
# This indicates that anything but objects can be read into a const variable.
const
{
	read_in = (!*object);
}
# This means that numbers are valid, as are upper- and lower-case hexadecimals characters A-F.
hexadecimal
{
	read_in = (*number, A, B, C, D, E, F, a, b, c, d, e, f);
}

Limiting Attributes

Another attribute is the unmodifiable attribute. This is used to force the compiler to disallow modifications of the variable type. There are three valid values for this attribute:

  • function_modification: Dissallows the modification of functions already used by the variable type
  • function_definition: Dissallows the definition of functions for the variable type.
  • variables: Dissallows the definition of variables for the variable type.

If the unmodifiable attribute is included and not set equal to any values, then it will assume all three are true.

# Because the unmodifiable attribute is defined for global, and because it doesn't have any values explicitly stated, the global
# variable type isn't able to have functions modified or defined, and can not have variable defined.
global
{
	unmodifiable;
}

The last attribute is the create_on_start attribute. This one is fairly self-explanatory. When included, the variable type will be created when the world starts up. This also sets it so that this variable type is the only type that can legally exist. When referring to a function or variable held by this type of variable-type, simply do variable_type.function() or variable_type.variable.

# As the create_on_start attribute is defined here, global will be created as soon as any program with this spec file included is
# launched, and any attempt at creating another version will result in an error.
global
{
	create_on_start;
}

Indicator Attribute

Each data type has to be assigned a unique indicator so that the interpreter can handle the variable type. This is specified in the specification file by the indicator attribute. By default, the var data type is assigned the address 0x01, and this can not be overwritten. Any other data type can be given whatever value, though two different types can not have the same indicator. This will cause a compile-time error.

  • Note: The hexadecimal value can be of any length. 0xDEADBEEF is just as valid as 0x1
# This gives the char data type the indicator of 0x02.
char
{
	indicator = 0x02;
}

Example: The Standard Format File

# STANDARD FORMAT FOR FIZZFUZZ COMPILER SPECIFICATIONS

# This is the standard format for the FizzFuzz compiler. While providing the basic standard for
# the FizzFuzz compiler to work on, it also provides an example on how to set up a FizzFuzz
# specification file. Specification files are used to tell the FizzFuzz compiler how to interpret
# different input. This serves the purpose of error-handling and syntax highlighting.

# var is the parent-type of all variable types. Any internal modifications to it will make all
# other variable types act differently. var is implied in spec files, and is only explicitly
# stated here for consistency.

var {}

char
{
	functions = (ascii);
	read_in = (*text);

	indicator = 0x02;
}

string
{
	functions = (length, concatenate, copy, get_character, truncate, ascii);
	variables = (length);
	read_in = (*text);

	indicator = 0x03;
}

number
{
	functions = (round, floor, ceiling, truncate, absolute);
	read_in = (*numeric);

	indicator = 0x04;
}

integer
{
	read_in = (*numeric);
	indicator = 0x05;
}

unsigned
{
	read_in = (*numeric);
	indicator = 0x06;
}

const
{
	read_in = (!*object);
	indicator = 0x07;
}

ext_const
{
	read_in = (!*object);
	indicator = 0x08;
}

boolean
{
	indicator = 0x09;
}

list
{
	functions = (intialize, add, remove, cut, copy, find, insert, swap, replace);
	variable = (length);

	indicator = 0x0A;
}

object
{
	functions = (*reference);
	variables = (*reference);
	read_in = (*object);

	indicator = 0x0B;
}

# global is a special variable type that is used to send and recieve information on the connected
# world (meaning /world in DM). On top of that, this has the function of being used to call
# miscellaneous functions. Note that these functions only affect the scope of the code block they
# are contained in.

global
{
	functions = (output, send, recieve, call, round, floor, ceiling, truncate, abs, length, concatenate, copy, get_character,
		     ascii2text, text2ascii, spawn, sleep);
	unmodifiable;
	create_on_start;

	indicator = 0x0C;
}
Personal tools
Navigation
functions
language