<<<<<<<<<<<<<<<<<

parser(lymb) LYMB parser(lymb)

NAME

parser

SUPERCLASS

object

DESCRIPTION

The LYMB parser is an object that users interact with via scripts. The parser cannot be instanced.

INSTANCE VARIABLES

level is the level of recursion.

lines_parsed is the number of lines parsed.

prompt is the prompt. When a recursive interactive level is begun, either by pressing the interrupt key (usually ^C), or by sending the parser an "interactive!" message, the prompt is preceeded by the recursion level in square brackets. The prompt also indicates the current number of open `'-style strings.

MESSAGES

break! sets a breakpoint into a symbolic debugger at that line of the LYMB script. If LYMB is not being run from a debugger, this message has no effect.

build_time? return the time at which the current LYMB executable was built.

exit_actions= arguments sets the exit_actions for the parser to the list of objects given in the argument list. Each argument will receive a tick! message upon exit. Normally, this message should not be used, in favor of "exit_actions+", to avoid accidentally deleting other exit_actions that might have been added from other parts of the application.

exit_actions+ arguments adds the arguments to the list of exit_actions for the parser.

exit_actions- arguments removes the arguments from the list of exit_actions for the parser.

exit_actions? returns the list of actions that are currently scheduled to be executed upon exit.

file_trace! print the name of each file as it is entered and exited.

full_trace! print each line as it is parsed and the name of each file as it is entered and exited.

interactive! creates a new input stream for the parser. The parser will continue to accept input from this stream until it receives an EOF (^D for Unix, ^Z for VMS).

lymb_version? returns the version of LYMB that was used to create this executable. The version number consists of a major version followed by the minor version.

parse: argument parses a user provided string. The parser can process any valid LYMB statement. The same syntax that applies to interactive statements applies to parse: strings.

parse_fileptr:argument The argument is a file pointer (value of type (FILE *) in C). This message creates a new stream and begins a recursive invocation of the parser.

parsed! prints, on standard output, a count of the number of statements parsed by the parser.

prompt= argument sets the parser's prompt string to its argument.

trace_off! disable file name and line tracing.

trace_on! enable file name and line tracing.

single_step_on! enables single-stepping by the parser. An interactive parser is started up after each parser statement is executed. (new parser only).

single_step_off! disables single-step mode (new parser only).

expand_aliases_on! enables alias expansion in the parser.

expand_aliases_off! disables alias expansion in the parser.

alias+(name,alias,...) adds an alias pair to the parser. If alias expansion is enabled, whenever "name" is encountered as an object name or a string parameter, it will be replaced with "alias". Any number of name/alias pairs can be given as arguments.

alias+(name,...) removes an alias pair from the parser. Any number of names can be given as arguments.

parse_file:(filename,...) reads and parses the argument file(s).

SYNTAX

The language consists entirely of objects and messages. In the excerpts from the YACC description of the language that follow, capitalized items are tokens recognized by the lexical analyzer LEX. A ":=" separates the left-hand side of each production in the grammar from its right-hand side. If there are several rules with the same left-hand side, a vertical bar, "|", is used as rule's separator.

statement := object messages ";" object := NAME messages := message | messages message message := PREFIX "?" | PREFIX "!" | PREFIX "#" | PREFIX ":" argument | PREFIX "=" argument | PREFIX "@" argument | PREFIX "+" argument | PREFIX "-" argument | PREFIX "/" argument | PREFIX "*" argument | PREFIX "^" argument argument:= VALUE | NAME | STRING | "(" argument_list ")" | "[" object messages "]" argument_list:= argument | argument_list "," argument

In the above description, VALUE is a floating point number, NAME is a string of characters, STRING is a quoted string, and PREFIX is an optional string. The language also allows for C language style comments. To identify the end of a LYMB statement for those objects that care about it, the parser sends an "end_of_message"

message to the current object when it sees a semicolon (";") in the input stream. Some special characters at the start of a line allow the user to do redirection of input and output, invoke system routines, and print text at the terminal.

! or # These characters in the first column of a line will echo this line on standard output.

? This character in the first column of a line will print a brief help message.

$ This character in the first column of a line will start a new shell process. Return to the system is done with exit command.

$ argument This sequence started in the first column of a line executes shell command specified by argument and then returns to the system.

file This sequence started in the first column of a line causes parser to accept input from the named file. ~ expansion is performed on the file before opening it.

>file This sequence started in the first column of a line causes parser to log system output to the named file. ~ expansion is performed on the file before opening it.

[ ] The left and right square brackets allow the arguments to a message to be obtained from another object. The semantics of messages are implemented within the objects themselves. The following rules for message suffixes illustrate message semantics.

? indicates a request for the value of an instance variable.

= indicates the setting of an instance variable.

: is used for messages that require arguments, but do not specifically set an instance variable.

@ is used for indexing messages.

+,-, /,*, ^ terminate arithmetic operation messages.

! is used for actions not requiring arguments.

# is used for actions requiring argument.

EXAMPLE

-- change prompt parser prompt= "visage> "; -- build a string and send it to the parser scalar new: sc1 = 4; scalar new: sc2 = 5; collection new: col1 members=[scalar instances?]; string new: str1 = "str2 = [col1 value?];"; string new: str2; parser parse: str1; -- add to exit actions to be executed upon termination actions new: `delete_motif_objects' tick_actions=` collection new! members=[motif instances?] freeall! free! ; ' ; parser exit_actions+`delete_motif_objects';

SEE ALSO

object, msg, collection, actions, alias_generator


Please send comments and suggestions to
consult@rpi.edu