Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Related Pages

Command - The CDG Scripting Language


Detailed Description

Author:
Ingo Schroeder (see also AUTHORS and THANKS for more)
Id
command.c,v 1.309 2004/10/04 14:36:12 micha Exp

This module implements the CDG scripting interface, that is, all the commands that are available on the cdgp prompt or executable via commandEval().

Note: do not confuse the scripting interface language with the constraint grammar language or the language bindings. They are all separate things.

Each valid command corresponds to a C function cmdCommand that implements this command all commands are listed in interface_commands. Each command is defined by a Command - The CDG Scripting Language structure, where the name, the interface completion commands, a little help message for that command etc are defined.

The following commands exist:


Data Structures

struct  Command

Defines

#define STARTUPMSG

Typedefs

typedef Boolean CommandFunction (int no, char **args)

Functions

char * annotation_completion_function (const char *, int)
Boolean cmdActivate (int no, char **args)
Boolean cmdAnno2Parse (int no, char **args)
Boolean cmdAnnos2prolog (int no, char **args)
Boolean cmdAnnotation (int no, char **args)
Boolean cmdChart (int no, char **args)
Boolean cmdChunk (int no, char **args)
Boolean cmdCloseDB ()
Boolean cmdCompareParses (int no, char **args)
Boolean cmdCompile (int no, char **args)
Boolean cmdConstraint (int no, char **args)
Boolean cmdDeactivate (int no, char **args)
Boolean cmdDistance (int no, char **args)
Boolean cmdEdges (int no, char **args)
Boolean cmdFrobbing (int no, char **args)
Boolean cmdGls (int no, char **args)
Boolean cmdHelp (int no, char **args)
Boolean cmdHierarchy (int no, char **args)
Boolean cmdHook (int no, char **args)
Boolean cmdIncrementalCompletion (int no, char **args)
Boolean cmdInputwordgraph (int no, char **args)
Boolean cmdISearch (int no, char **args)
Boolean cmdLevel (int no, char **args)
Boolean cmdLevelsort (int no, char **args)
Boolean cmdLexicon (int no, char **args)
Boolean cmdLicense (int no, char **args)
Boolean cmdLoad (int no, char **args)
Boolean cmdLs (int no, char **args)
Boolean cmdNet (int no, char **args)
Boolean cmdNetdelete (int no, char **args)
Boolean cmdNetsearch (int no, char **args)
Boolean cmdNewnet (int no, char **args)
Boolean cmdNonSpecCompatible (int no, char **args)
Boolean cmdParsedelete (int no, char **args)
Boolean cmdParses2prolog (int no, char **args)
Boolean cmdPrintParse (int no, char **args)
Boolean cmdPrintParses (int no, char **args)
Boolean cmdQuit (int no, char **args)
Boolean cmdRenewnet (int no, char **args)
Boolean cmdReset (int no, char **args)
Boolean cmdSection (int no, char **args)
Boolean cmdSet (int no, char **args)
Boolean cmdShift (int no, char **args)
Boolean cmdShowlevel (int no, char **args)
Boolean cmdStatus (int no, char **args)
Boolean cmdTagger (int no, char **args)
Boolean cmdTesting (int no, char **args)
Boolean cmdUseconstraint (int no, char **args)
Boolean cmdUselevel (int no, char **args)
Boolean cmdUseLexicon (int no, char **args)
Boolean cmdVerify (int no, char **args)
Boolean cmdVersion (int no, char **args)
Boolean cmdWeight (int no, char **args)
Boolean cmdWordgraph (int no, char **args)
Boolean cmdWriteAnno (int no, char **args)
Boolean cmdWriteNet (int no, char **args)
Boolean cmdWriteParses (int no, char **args)
Boolean cmdWriteWordgraph (int no, char **args)
char * command_completion_function (const char *, int)
Boolean commandEval (String line)
Boolean commandLoop (String prompt)
char * constraint_completion_function (const char *, int)
char * frob_method_completion_function (const char *, int)
String getNextArgument (String s, int *index, int stop)
char * hierarchy_completion_function (const char *, int)
char * hook_completion_function (const char *, int)
char ** interface_completion (String text, int start, int end)
char * level_completion_function (const char *, int)
char * levelsort_completion_function (const char *, int)
char * lexicon_completion_function (const char *, int)
char * make_rl_string (char *)
char * net_completion_function (const char *, int)
char * parse_completion_function (const char *, int)
char * search_method_completion_function (const char *, int)
char * section_completion_function (const char *, int)
char * set_completion_function (const char *, int)
char * word_completion_function (const char *, int)
char * wordgraph_completion_function (const char *, int)

Variables

Boolean commandLoopFlag = TRUE
List interface_cell = NULL
Command interface_commands []
HashIterator interface_hashiterator = NULL
int interface_index = 0
int interface_length = 0
List interface_list = NULL


Define Documentation

#define STARTUPMSG
 

Value:

"\nCDG parser version " VERSION ", build " BUILD "\n" \ "\n" \ "Copyright (C) 1997-2004 The CDG Team\n"\ "The CDG parser comes with ABSOLUTELY NO WARRANTY.\n"\ "This is free software, and you are welcome to redistribute it\n"\ "under certain conditions; type `license' for details.\n"\ "\n"\ "For more information see\n"\ "\n"\ " http://nats-www.informatik.uni-hamburg.de/~dawai\n"\ "\n"\ "The CDG Team can be contacted at\n"\ "\n"\ " cdg@nats.informatik.uni-hamburg.de\n"\ "\n"\ "Type `help' for a short help.\n"\ "\n"\ "\n"\ ""
message to be displayed at startup Definition at line 30 of file command.h.

Referenced by cmdVersion().


Typedef Documentation

typedef Boolean CommandFunction(int no, char **args)
 

type of a function that implements a scripting command.

The first parameter no is the number of arguments entered by the user after the command name. The array args holds these arguments as a list of plain strings. For example, the command "\c newnet \c s1" contains one command and argument. To handle it, the function cmdNewnet() will be called with two arguments: the number 1 (as we have one argument) and an array containing the argument strings, which is one here: "s1".

The job of a CommandFunction() is to check the arguments for consistency and then either execute the action specified by the command or give reasons why they are incorrect.

Each command returns a Boolean which is TRUE on a successful command execution and otherwise FALSE, that is when an error occurred. Definition at line 161 of file command.c.


Function Documentation

char * annotation_completion_function const char *  text,
int  state
 

Compute completions for annotations. Definition at line 643 of file command.c.

References interface_cell, interface_length, interface_list, make_rl_string(), and NULL.

Boolean cmdActivate int  no,
char **  args
 

Activate constraint classes.

All constraint classes that are named as arguments are activated, that is, their field ->active is set to TRUE. The effect is that these constraints are used (again) for evaluation. Since this changes the basis of evaluation, this is treated like a change in the grammar, i.e. all previously computed structures become invalid and are deleted. Definition at line 1894 of file command.c.

References cdgDeleteComputed(), FALSE, NULL, and TRUE.

Boolean cmdAnno2Parse int  no,
char **  args
 

Build a parse from an annotation and evaluate it against the current grammar. Definition at line 1633 of file command.c.

References CDG_ERROR, CDG_INFO, CDG_PROGRESS, CDG_WARNING, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), dbAvailable(), dbLoadAll(), FALSE, lgDelete(), lgNew(), NULL, and TRUE.

Boolean cmdAnnos2prolog int  no,
char **  args
 

Save all annotations to a file in Prolog format. Definition at line 4008 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdAnnotation int  no,
char **  args
 

Print the specified annotation entries. Definition at line 1593 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdChart int  no,
char **  args
 

Perform chart-based search. Definition at line 4049 of file command.c.

Boolean cmdChunk int  no,
char **  args
 

Chunk the specified wordgraph. Definition at line 3825 of file command.c.

References CDG_ERROR, CDG_INFO, CDG_PROFILE, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), Chunker, chunkerChunk(), chunkerDelete(), chunkerNew(), chunkerPrintChunks(), DefaultChunker, FALSE, lgDelete(), lgNew(), NULL, Timer, timerElapsed(), timerFree(), timerNew(), and TRUE.

Boolean cmdCloseDB  ) 
 

Close the lexicon database. Definition at line 3960 of file command.c.

References dbClose().

Boolean cmdCompareParses int  no,
char **  args
 

Compare the specified parses. Definition at line 1926 of file command.c.

References CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgParses, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdCompile int  no,
char **  args
 

Compile current grammar.

Currently broken. Definition at line 1198 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), comCompile(), comLoad(), evalEvaluationMethod, FALSE, and TRUE.

Boolean cmdConstraint int  no,
char **  args
 

Print the specified constraints. Definition at line 1229 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdDeactivate int  no,
char **  args
 

Deactivate constraint classes.

All constraint classes that are named as arguments are deactivated, that is, their field ->active is set to FALSE. The effect is that these constraints are not used for evaluation, as if they had never been defined. Since this changes the basis of evaluation, this is treated like a change in the grammar, i.e. all previously computed structures become invalid and are deleted. Definition at line 1855 of file command.c.

References cdgDeleteComputed(), FALSE, NULL, and TRUE.

Boolean cmdDistance int  no,
char **  args
 

Print the distance matrix of the specified net. Definition at line 3392 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgPrintf(), cnFindNet(), ConstraintNet, FALSE, GraphemNode, LexemGraphStruct::graphemnodes, LexemNodeStruct::lexem, ConstraintNetStruct::lexemgraph, LexemNode, lgDistanceOfNodes(), NULL, and TRUE.

Boolean cmdEdges int  no,
char **  args
 

Print edges of the specified constraint net. Definition at line 2440 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgNets, cdgPrintf(), cnPrintEdge(), ConstraintEdge, ConstraintNet, ConstraintNode, ConstraintNetStruct::edges, FALSE, ConstraintNetStruct::id, ConstraintNetStruct::nodes, NULL, ConstraintEdgeStruct::start, ConstraintEdgeStruct::stop, and TRUE.

Boolean cmdFrobbing int  no,
char **  args
 

Try to find a complete solution by transformation. Definition at line 2241 of file command.c.

References cdgCtrlCAllowed, cdgCtrlCTrapped, cdgTimeLimit, FALSE, timerSetAlarm(), timerStopAlarm(), and TRUE.

Boolean cmdGls int  no,
char **  args
 

Subject the specified net to a guided local search for global solutions. Definition at line 3770 of file command.c.

Boolean cmdHelp int  no,
char **  args
 

Print the help string for the specified CDG command. Definition at line 3905 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgPrintf(), FALSE, interface_commands, name, NULL, and TRUE.

Boolean cmdHierarchy int  no,
char **  args
 

Print the specified hierarchies. Definition at line 1769 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdHook int  no,
char **  args
 

Set or query hooks. Definition at line 3680 of file command.c.

References HookStruct::active, CDG_DEFAULT, CDG_ERROR, CDG_HOOK, CDG_INFO, cdgPrintf(), HookStruct::count, FALSE, hkFindNoOfHook(), hkHooks, hkVerbosity, Hook, HookStruct::name, NULL, and TRUE.

Boolean cmdIncrementalCompletion int  no,
char **  args
 

Parsing problems are created incrementally over prefixes of the word graph and solved individually, with the solution of one problem guiding the search in the next one. Definition at line 3503 of file command.c.

References CDG_ERROR, CDG_INFO, CDG_PROFILE, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), cnEdgesFlag, CnEdgesType, FALSE, NULL, scUseCache, Timer, timerElapsed(), timerFree(), timerNew(), and TRUE.

Boolean cmdInputwordgraph int  no,
char **  args
 

Build a new wordgraph. Definition at line 3346 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdISearch int  no,
char **  args
 

Perform a complete search on increasing prefixes of the word graph. Definition at line 3563 of file command.c.

References CDG_ERROR, CDG_INFO, CDG_PROFILE, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgNets, cdgPrintf(), cnMostRecentlyCreatedNet, ConstraintNet, FALSE, NULL, Timer, timerElapsed(), timerFree(), timerNew(), and TRUE.

Boolean cmdLevel int  no,
char **  args
 

Print the specified level declarations. Definition at line 1253 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdLevelsort int  no,
char **  args
 

Sort all levels according to the specified order and display the new order. Definition at line 3660 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), FALSE, and TRUE.

Boolean cmdLexicon int  no,
char **  args
 

Print the specified lexicon entries. Definition at line 1454 of file command.c.

References CDG_DEFAULT, CDG_INFO, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdLicense int  no,
char **  args
 

Print the General Public License. Definition at line 2948 of file command.c.

References CDG_DEFAULT, cdgPrintf(), and TRUE.

Boolean cmdLoad int  no,
char **  args
 

Load one or more files. Definition at line 2871 of file command.c.

References CDG_ERROR, CDG_INFO, cdgDeleteComputed(), cdgExecPragmas(), cdgPrintf(), evalEvaluationMethod, FALSE, NULL, and TRUE.

Boolean cmdLs int  no,
char **  args
 

List one or more files.

This simply spawns the system command ls. Definition at line 1163 of file command.c.

References CDG_ERROR, CDG_WARNING, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdNet int  no,
char **  args
 

Print the specified constraint net. Definition at line 2021 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgNets, cdgPrintf(), cnMostRecentlyCreatedNet, cnPrint(), ConstraintNet, FALSE, NULL, and TRUE.

Boolean cmdNetdelete int  no,
char **  args
 

Delete constraint nets.

If no argument is given, delete all known constraint nets. Otherwise, delete all named nets. Definition at line 2389 of file command.c.

References CDG_ERROR, cdgNets, cdgPrintf(), cdgProblems, cnDelete(), cnMostRecentlyCreatedNet, ConstraintNet, FALSE, and NULL.

Boolean cmdNetsearch int  no,
char **  args
 

Perform a complete search for globally best solution. Definition at line 2115 of file command.c.

References CDG_ERROR, CDG_INFO, CDG_SEARCHRESULT, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgNets, cdgPrintf(), cnMostRecentlyCreatedNet, cnPrintInfo(), cnPrintParses(), ConstraintNet, FALSE, hkVerbosity, ConstraintNetStruct::id, NULL, ConstraintNetStruct::parses, and TRUE.

Boolean cmdNewnet int  no,
char **  args
 

Build a new constraint net. Definition at line 3246 of file command.c.

References CDG_ERROR, CDG_INFO, CDG_PROFILE, CDG_WARNING, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgNets, cdgPrintf(), cnBuild(), cnPrintInfo(), ConstraintNet, FALSE, ConstraintNetStruct::id, NULL, Timer, timerElapsed(), timerFree(), timerNew(), and TRUE.

Boolean cmdNonSpecCompatible int  no,
char **  args
 

Report whether the specified constraints are suitable for processing underspecified subordinations. Definition at line 3449 of file command.c.

References CDG_DEFAULT, CDG_ERROR, CDG_INFO, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdParsedelete int  no,
char **  args
 

Delete the specified parse. Definition at line 2305 of file command.c.

References CDG_ERROR, CDG_INFO, cdgParses, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdParses2prolog int  no,
char **  args
 

Save all parses to a file in Prolog format. Definition at line 3969 of file command.c.

References CDG_ERROR, CDG_INFO, cdgParses, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdPrintParse int  no,
char **  args
 

Prints the specified Parse on stdout. Definition at line 1975 of file command.c.

References CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgParses, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdPrintParses int  no,
char **  args
 

Print parses of the specified net. Definition at line 2266 of file command.c.

References CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), cnFindNet(), cnMostRecentlyCreatedNet, cnPrintInfo(), cnPrintParses(), ConstraintNet, FALSE, NULL, ConstraintNetStruct::parses, and TRUE.

Boolean cmdQuit int  no,
char **  args
 

Leave the command loop.

See also:
commandLoop
Definition at line 1151 of file command.c.

References commandLoopFlag, FALSE, and TRUE.

Referenced by commandLoop().

Boolean cmdRenewnet int  no,
char **  args
 

Restore the specified net to original state. Definition at line 3306 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), cnFindNet(), cnMostRecentlyCreatedNet, cnPrintInfo(), cnRenew(), ConstraintNet, FALSE, NULL, and TRUE.

Boolean cmdReset int  no,
char **  args
 

Discard all loaded and computed information. Definition at line 2847 of file command.c.

References CDG_ERROR, cdgDeleteComputed(), cdgPrintf(), FALSE, and TRUE.

Boolean cmdSection int  no,
char **  args
 

Print the specified constraint sections. Definition at line 1799 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdSet int  no,
char **  args
 

Set the specified CDG variable. Definition at line 1820 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), FALSE, and NULL.

Boolean cmdShift int  no,
char **  args
 

Simulate shift-reduce parsing. Definition at line 1318 of file command.c.

References cdgCtrlCAllowed, cdgCtrlCTrapped, cdgTimeLimit, FALSE, timerSetAlarm(), timerStopAlarm(), and TRUE.

Boolean cmdShowlevel int  no,
char **  args
 

Toggle whether the specified level is shown or not. Definition at line 1343 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdStatus int  no,
char **  args
 

Print status information. Definition at line 2659 of file command.c.

References CDG_DEBUG, CDG_DEFAULT, CDG_ERROR, CDG_EVAL, CDG_HINT, CDG_HOOK, CDG_INFO, CDG_PROFILE, CDG_PROGRESS, CDG_PROLOG, CDG_SEARCHRESULT, CDG_WARNING, CDG_XML, cdgNets, cdgParses, cdgPrintf(), cnEdgesFlag, cnShowDeletedFlag, cnSortNodesMethod, cnUnaryPruningFraction, evalEvaluationMethod, evalPeekValueMethod, evalSloppySubsumesWarnings, hkVerbosity, lgCompactLVs, NULL, scUseCache, and TRUE.

Boolean cmdTagger int  no,
char **  args
 

Start or stop the tagger. Definition at line 2168 of file command.c.

References CDG_ERROR, cdgPrintf(), FALSE, and TRUE.

Boolean cmdTesting int  no,
char **  args
 

Undocumented command for testing mode=1: determine base line for accuracy mode=2: determine base line for accuracy (TODO: is that correct??) mode=3: compare two lexica bit for bit mode=4: approve compiled grammar Definition at line 2193 of file command.c.

References CDG_ERROR, cdgPrintf(), comApprove(), FALSE, and TRUE.

Boolean cmdUseconstraint int  no,
char **  args
 

Toggle whether the specified constraint is used or not. Definition at line 1380 of file command.c.

References CDG_ERROR, CDG_INFO, cdgDeleteComputed(), cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdUselevel int  no,
char **  args
 

Toggle whether the specified level is used or not. Definition at line 1411 of file command.c.

References CDG_ERROR, CDG_INFO, cdgDeleteComputed(), cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdUseLexicon int  no,
char **  args
 

Specifies a file to be used for autoloading lexicon items.

The parameter must be string that is used as the file name. The file of cdg input must be called S.cdg, and the index must be called S.db.

If these files are not in the current working directory they are also searched in other directories that input was loaded from. Definition at line 3942 of file command.c.

References CDG_ERROR, cdgPrintf(), dbOpen(), FALSE, and TRUE.

Boolean cmdVerify int  no,
char **  args
 

Compare parse to annotation. Definition at line 3778 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdVersion int  no,
char **  args
 

Print the CDG version. Definition at line 3236 of file command.c.

References CDG_DEFAULT, cdgPrintf(), STARTUPMSG, and TRUE.

Boolean cmdWeight int  no,
char **  args
 

Adjust the weight of a constraint. Definition at line 2060 of file command.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), FALSE, and TRUE.

Boolean cmdWordgraph int  no,
char **  args
 

Print wordgraphs. Definition at line 1508 of file command.c.

References CDG_DEFAULT, CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), FALSE, NULL, and TRUE.

Boolean cmdWriteAnno int  no,
char **  args
 

Write best Parse of a net to disk as an annotation. Definition at line 2540 of file command.c.

References bCompare(), CDG_ERROR, cdgNets, cdgPrintf(), cnMostRecentlyCreatedNet, ConstraintNet, FALSE, ConstraintNetStruct::id, NULL, ConstraintNetStruct::parses, and TRUE.

Boolean cmdWriteNet int  no,
char **  args
 

Write the specified constraint net to an XFig file. Definition at line 2499 of file command.c.

References CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgNets, cdgPrintf(), cnMostRecentlyCreatedNet, ConstraintNet, FALSE, NULL, and TRUE.

Boolean cmdWriteParses int  no,
char **  args
 

Write the specified parses to XFig and LaTeX files. Definition at line 2586 of file command.c.

References CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), cnFindNet(), cnMostRecentlyCreatedNet, ConstraintNet, FALSE, NULL, ConstraintNetStruct::parses, and TRUE.

Boolean cmdWriteWordgraph int  no,
char **  args
 

Write the specified wordgraphs to XFig file. Definition at line 1547 of file command.c.

References CDG_ERROR, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgPrintf(), FALSE, NULL, and TRUE.

char * command_completion_function const char *  text,
int  state
 

Compute the completions for commands.

This is one of many functions provided to pass information to the readline library. These functions all have basically the same structure which is required by readline: they must return a newly allocated string every time they are called. They vary only in which strings are returned as possible completions.

The parameter "text" is the partial string typed by the user so far. The completion function must now offer the readline library suitable strings to complete it. This particular function knows what commands the CDG shell understands, so it iterates over the array interface_commands[] internally. The other completion functions will iterate over other structures, obviously. Definition at line 462 of file command.c.

References interface_commands, interface_index, interface_length, make_rl_string(), name, and NULL.

Referenced by interface_completion().

Boolean commandEval String  line  ) 
 

CDG command dispatch routine.

This function interprets one command of the scripting language.

Parameters:
line the command line to be evaluated
Returns:
TRUE on a successful command execution, otherwise FALSE.
Definition at line 1070 of file command.c.

References CDG_ERROR, CDG_XML, cdgFlush(), cdgFreeString(), cdgPrintf(), FALSE, function, getNextArgument(), hkVerbosity, interface_commands, name, NULL, and TRUE.

Referenced by cdgExecPragmas(), and commandLoop().

Boolean commandLoop String  prompt  ) 
 

CDG main event loop.

This function reads and executes commands and terminates when the commandLoopFlag has been set to FALSE.

Parameters:
prompt to be displayed at the command line
Returns:
the boolean result of the last command, that is TRUE on success and else FALSE.
Definition at line 1003 of file command.c.

References CDG_DEFAULT, CDG_WARNING, cdgPrintf(), cmdQuit(), commandEval(), commandLoopFlag, interface_completion(), NULL, and TRUE.

char * constraint_completion_function const char *  text,
int  state
 

Compute completions for constraints. Definition at line 499 of file command.c.

References interface_cell, interface_length, interface_list, make_rl_string(), and NULL.

char * frob_method_completion_function const char *  text,
int  state
 

Compute completions for frobbing methods. Definition at line 787 of file command.c.

References interface_index, interface_length, make_rl_string(), and NULL.

String getNextArgument String  s,
int *  index,
int  stop
 

Return a copy of the next command word in S.

Command words are searched in the part of S starting at INDEX and not exceeding STOP. Command words are separated by instances of the characters defined in rl_basic_word_break_characters by the readline library.

(void)strncpy(buffer, &s[start], *index - start - 1); buffer[*index - start - 1] = ''; Definition at line 859 of file command.c.

References CDG_WARNING, cdgPrintf(), cdgXCDG, and NULL.

Referenced by commandEval(), and interface_completion().

char * hierarchy_completion_function const char *  text,
int  state
 

Compute completions for hierarchies. Definition at line 668 of file command.c.

References interface_cell, interface_length, interface_list, make_rl_string(), and NULL.

char * hook_completion_function const char *  text,
int  state
 

Compute completions for known hooks. Definition at line 808 of file command.c.

References hkHooks, Hook, interface_index, interface_length, make_rl_string(), and NULL.

char ** interface_completion String  text,
int  start,
int  end
 

Provide context sensitive command completion.

This function is passed to the readline library as the rl_attempted_completion_function. See the readline documentation for details of its behaviour. Definition at line 932 of file command.c.

References args, cdgFreeString(), command_completion_function(), getNextArgument(), interface_commands, name, NULL, and same.

Referenced by commandLoop().

char * level_completion_function const char *  text,
int  state
 

Compute completions for the command level. Definition at line 523 of file command.c.

References interface_length, interface_list, make_rl_string(), and NULL.

char * levelsort_completion_function const char *  text,
int  state
 

Compute completions for the command levelsort. Definition at line 544 of file command.c.

References interface_length, interface_list, make_rl_string(), and NULL.

char * lexicon_completion_function const char *  text,
int  state
 

Compute completions for lexical entries. Definition at line 569 of file command.c.

References interface_hashiterator, interface_length, make_rl_string(), and NULL.

char * make_rl_string char *  s  ) 
 

Produce a string suitable for internal processing by readline.

This function serves two purposes:

  1. it accepts a string and returns a clone of it. This is necessary because the readline library insists on doing its own deallocating.

  1. if the string passed contains whitespace, it wraps quotes around it so that the CDG shell will parse it as one string later. That way, completion works even for identifiers with whitespace in them (highly discouraged but possible).

TODO: This is not yet quite correct. It can handle identifiers like "SYN", "um zu", and "it's". But it can fail if a string contains both whitespace and single quotes:

"Hand me the 'scope, skipper!"

My excuse is that I can think of no reason whatsoever why anybody would use that sort of identifier in a constraint grammar. Definition at line 432 of file command.c.

References NULL.

Referenced by annotation_completion_function(), command_completion_function(), constraint_completion_function(), frob_method_completion_function(), hierarchy_completion_function(), hook_completion_function(), level_completion_function(), levelsort_completion_function(), lexicon_completion_function(), net_completion_function(), parse_completion_function(), search_method_completion_function(), section_completion_function(), set_completion_function(), and wordgraph_completion_function().

char * net_completion_function const char *  text,
int  state
 

Compute completions for constraint nets. Definition at line 693 of file command.c.

References cdgNets, interface_cell, interface_length, interface_list, make_rl_string(), and NULL.

char * parse_completion_function const char *  text,
int  state
 

Compute completions for parses. Definition at line 830 of file command.c.

References cdgParses, interface_cell, interface_length, interface_list, make_rl_string(), and NULL.

char * search_method_completion_function const char *  text,
int  state
 

Compute completions for search methods. Definition at line 718 of file command.c.

References interface_index, interface_length, make_rl_string(), and NULL.

char * section_completion_function const char *  text,
int  state
 

Compute completions for sections. Definition at line 738 of file command.c.

References interface_length, interface_list, make_rl_string(), and NULL.

char * set_completion_function const char *  text,
int  state
 

Compute completions for the set command Definition at line 759 of file command.c.

References interface_index, interface_length, make_rl_string(), and NULL.

char * word_completion_function const char *  text,
int  state
 

Compute completions for orthographic words. Definition at line 593 of file command.c.

References interface_hashiterator, interface_length, and NULL.

char * wordgraph_completion_function const char *  text,
int  state
 

Compute completions for wordgraphs. Definition at line 620 of file command.c.

References interface_length, interface_list, make_rl_string(), and NULL.


Variable Documentation

Boolean commandLoopFlag = TRUE [static]
 

flag indicating the end of the command main loop. Entering the commandLoop() this is set to TRUE. commandLoop() exits if this global variable is set to FALSE. Definition at line 202 of file command.c.

Referenced by cmdQuit(), and commandLoop().

List interface_cell = NULL [static]
 

Todo:
Write an explanation of the interface and the completion gadget
Definition at line 192 of file command.c.

Referenced by annotation_completion_function(), constraint_completion_function(), hierarchy_completion_function(), net_completion_function(), and parse_completion_function().

Command interface_commands[]
 

array of all registered wcdg scripting commands. Definition at line 227 of file command.c.

Referenced by cmdHelp(), command_completion_function(), commandEval(), and interface_completion().

HashIterator interface_hashiterator = NULL [static]
 

Todo:
Write an explanation of the interface and the completion gadget
Definition at line 195 of file command.c.

Referenced by lexicon_completion_function(), and word_completion_function().

int interface_index = 0 [static]
 

Todo:
Write an explanation of the interface and the completion gadget
Definition at line 183 of file command.c.

Referenced by command_completion_function(), frob_method_completion_function(), hook_completion_function(), search_method_completion_function(), and set_completion_function().

int interface_length = 0 [static]
 

Todo:
Write an explanation of the interface and the completion gadget
Definition at line 186 of file command.c.

Referenced by annotation_completion_function(), command_completion_function(), constraint_completion_function(), frob_method_completion_function(), hierarchy_completion_function(), hook_completion_function(), level_completion_function(), levelsort_completion_function(), lexicon_completion_function(), net_completion_function(), parse_completion_function(), search_method_completion_function(), section_completion_function(), set_completion_function(), word_completion_function(), and wordgraph_completion_function().

List interface_list = NULL [static]
 

Todo:
Write an explanation of the interface and the completion gadget
Definition at line 189 of file command.c.

Referenced by annotation_completion_function(), constraint_completion_function(), hierarchy_completion_function(), level_completion_function(), levelsort_completion_function(), net_completion_function(), parse_completion_function(), section_completion_function(), and wordgraph_completion_function().


CDG 0.95 (20 Oct 2004)