Hugo (programming Language) - Language Construction

Language Construction

The Hugo language is a hybrid of several features to provide a command processing system. The system consists of a verb definition section, a property and attribute definition section, an object definition section, and a code section. One may assign multiple names to the same attribute or property through the alias parameter to an attribute or property.

The language is not case sensitive, although much of the code base in the standard library uses camel case for identifiers. Identifiers must start with a letter, and may contain letters, numbers and underscores. Strings are defined by using a double quote. Where it is necessary to include a double quote in a string, it may be escaped by preceding it with a backslash, i.e. \" . With the exception of quoted strings, lines must be explicitly marked as being continued by having the last character on the line to be a backslash.

The system provides for procedures, called a "routine" which may optionally return a value. All executable statements must be within a routine, there is no "default" mode to execute code outside of a routine. Comments may be specified anywhere that white space is acceptable, and are indicated by an exclamation point !. This causes anything remaining on the line from that point to be ignored. A special type of block comment for commenting a large area may be used by having the first two characters on a line begin with the comment !\ and the block comment is closed by the next occurrence of the inverse string \! .

Where a "block" is needed - a set of related values or a particular piece of executable code - it is indicated by encasing it in the open brace character { and closing it with the }, similar to the same functionality in the C language. As with a number of other programming languages, Hugo borrows from C for a number of features, including "escaping" some values by preceding them with a backslash, the use of the ++ symbol to increment a variable, and the { and } braces for block begin and block end, as noted earlier. Hugo borrows the use of the "print" command for displaying variables and the use of the semi-colon ( ; ) from the Basic programming language to indicate output that is not to be broken by a new line.

There are two mandatory routines, one named "init" and one named "main." Init is run once when the program starts, and as the name implies, initializes anything the system needs to do. After Init ends, the routine "main" is run on every turn, a "turn" being used in the sense that each command issued by the player is a new turn. The main routine is used to do the typical housekeeping on each turn. The user is prompted for input, the parser processes the input to translate it into a verb and options to the verb, then determine the routine that processes that verb. The routine then returns a set of responses to the verb and options (if any), and the user is then prompted to type in a command.

The system requests commands and continues to do so until a routine indicates the program is over. Since the system was originally designed for writing of games, the determination of the program being over is typically because either because the player "won" according to the rules for that game, or because the player "lost".

Read more about this topic:  Hugo (programming Language)

Famous quotes containing the words language and/or construction:

    The writer’s language is to some degree the product of his own action; he is both the historian and the agent of his own language.
    Paul De Man (1919–1983)

    There’s no art
    To find the mind’s construction in the face.
    William Shakespeare (1564–1616)