HistoryCal - V0.0.7 Manual
Define grammar
Home Development V0.0.7 Manual Script Define grammar

grammar Statement

The grammar statement contains a number of sub-statements which describe how the attached schemes' input and output is written.

The grammar must be given a unique (within all other grammars) code name by which it can be referred to. It may then contain the following sub-statements in between '{' and '}' braces.

grammar Sub-Statement List
Sub-StatementUseExample
inheritInherit all the settings from a previously defined grammar.inherit j;
fieldsList of base fields, must match base order.fields year month day;
optionalUse the listed optional fields.optional wday, ce, ceyear;
rankThe field ranking used by the format sub-statements.rank ce, ceyear, month, day, wday;
lexiconsThe list of lexicons used with this grammar.lexicons m, w, jce;
calculateCalculate an element based on other fields.calculate Era {output @if(year<500,ce,?);}
aliasAllow the use of more user friendly field names.alias field {WDay, wday; ...}
formatThe description of a format.format dmy, "(Day) |(Month:m:a) |(Year)";
prefThe preferred format to use, unless otherwise stated.pref dmy;

inherit Sub-Statement

Create a new grammar by extending an existing one. The action of the original grammar is not changed in any way.

fields Sub-Statement

Declare the fields that match the scheme base fields. This list is checked whenever the grammar is attached to a scheme. If the match fails, an error is generated.

If the grammar inherits, then the inherited fields are appended to these fields, if any.

optional Sub-Statement

Declare all the optional fields required. The format definitions can only refer to the default fields for the base calendar plus the extended fields listed here.

This sub-statement must be positioned before any sub-statement that uses these fields.

rank Sub-Statement

This is the ranking order to be used by the format statements, unless the format statement has its own rank sub-statement.

lexicons Sub-Statement

Declare all the lexicon statements to be used. The format definitions can only refer to the lexicons listed here.

calculate Sub-Statement

Creates a new field which is not part of the scheme's record, but related to it by means of a mathematical expression.

grammar calculate Sub-Statement
Sub-StatementUseExample
outputAn expression to process the element before outputting.output @if( year<500, ce, ? );
pseudoThe text to show in the pseudo date for this element.pseudo "[CE<500]";

alias Sub-Statement

Provide user friendly alternative names for the base and optional field names. Because HistoryCal Script is case sensitive and the built-in field name are always lower case, the alias sub-statement is often used to give a proper cased name.

When referring to a field by name, either the alias or the default name may be used.

The alias has one of the type names listed in the table below, followed by a series of name pairs giving the alias name followed by a comma and then the field name. The pairs are separated by ';' semi-colons and the list enclosed in between '{' and '}' braces.

grammar alias Sub-Statement
Sub-StatementUseExample
alias fieldAllow the use of more user friendly field names.alias field {WDay, wday; ...}
alias pseudoThe pseudonym matching numbers in the pseudo date.alias pseudo {w, WDay; dd, Day; ...}
alias unitAlternative field name when used as a unit.alias field {d, day; m, month; ...}

alias field Sub-Statement

Create user friendly names for the fields used in the format strings.

alias pseudo Sub-Statement

When the date format needs to show that numbers will be displayed for a particular element in a particular position, the pseudo alias shown here will be used in creating the pseudo date.

alias unit Sub-Statement

This area is still being worked and evolving.

The universal unit format ":u" expects input in one or more 'number unit' pairs. The unit given is (in order of lookup) the unit alias, the field alias or the default field name.

format Sub-Statement

Apart from the grammar:format signature, the format sub-statement is the same as format statement.

A grammar may have many format sub-statements.

pref Sub-Statement

The preferred format to use. If this sub-statement is missing, the first format listed is used.

Home Development V0.0.7 Manual Script Define grammar

Managed by WebPageLayout Validated by HTML Validator (based on Tidy)

12th October 2016