Main Page | Data Structures | File List | Data Fields | Globals

parse.h File Reference

Simple functions commonly needed in parsing files. More...

#include <glib.h>

Go to the source code of this file.

Data Structures

struct  LUAU_parsedLine
 A line of input sorted into its identifier and its arguments. More...


Functions

LUAU_parsedLinelutil_parse_parseLine (char *input)
 Parse a line of input.

char lutil_parse_parseSymbol (const char *input, const GPtrArray *symbols)
 Compare a keyword to a list of valid symbols.

char lutil_parse_parseSymbolArray (const char *input, const char *symbols[])
 Compare a keyword to a list of valid symbols.

void lutil_parse_freeParsedLine (LUAU_parsedLine *line)
 Free a LUAU_parsedLine pointer.

char * lutil_parse_nextToken (char *input)
 Find the next token in a given line of input.

char * lutil_parse_nextToken_r (char *input, char **ptrptr)
char * lutil_parse_deleteWhitespace (char *string)
 Skip leading whitespace and delete trailing whitespace.

char * lutil_parse_skipString (char *input, char *string)
 Skip a string in the given line of input.


Detailed Description

Simple functions commonly needed in parsing files.

These are used by lutil_parseUpdateFile in parsing downloaded update files, and also by the command-line utility luau in parsing user input during interactive mode.

Definition in file parse.h.


Function Documentation

char* lutil_parse_deleteWhitespace char *  string  ) 
 

Skip leading whitespace and delete trailing whitespace.

Note that this "skips" leading whitespace by just returning a pointer to where the actual text in the string begins - nothing is actually deleted. Trailing whitespace is "deleted" by overwriting it with the null character ('\0').

  • string is the string to modify
    Returns:
    a pointer to the same string with white-space removed.

Definition at line 238 of file parse.c.

Referenced by parseGenericInfo(), parsePackage(), and parseSoftware().

void lutil_parse_freeParsedLine LUAU_parsedLine line  ) 
 

Free a LUAU_parsedLine pointer.

Free the memory allocated for a LUAU_parsedLine. Note that this function also frees the structure pointer itself.

Definition at line 126 of file parse.c.

References LUAU_parsedLine::args, and LUAU_parsedLine::keyword.

char* lutil_parse_nextToken char *  input  ) 
 

Find the next token in a given line of input.

Tokens are separated by whitespace. Tokens can have whitespace in them through the use of escaping (this\ is\ one\ token) or quoting ("this is one token"). Multi-line quotes or even multi-line input is not allowed.

To use: Call lutil_parse_nextToken once with the line of input to parse to get the first token.. Then call repeatedly with a NULL argument to retrieve any additional arguments. Returns null when end of line is reached.

  • input is the line of input to parse (or NULL to continue parsing last line given).
    Returns:
    the next token found

Definition at line 154 of file parse.c.

References lutil_parse_nextToken_r().

char* lutil_parse_nextToken_r char *  input,
char **  ptrptr
 

Definition at line 161 of file parse.c.

References ERROR.

Referenced by lutil_parse_nextToken(), and lutil_parse_parseLine().

LUAU_parsedLine* lutil_parse_parseLine char *  input  ) 
 

Parse a line of input.

lutil_parse_parseLine is really a front-end for using lutil_parse_nextToken, which is calls and places the output into a nicely structured LUAU_parsedLine. keyword is simply the first token of the input, and args is just an array of the rest of the tokens.

  • input is the line of input to parse
    Returns:
    input parsed into a LUAU_parsedLine object

Definition at line 46 of file parse.c.

References LUAU_parsedLine::args, LUAU_parsedLine::keyword, and lutil_parse_nextToken_r().

char lutil_parse_parseSymbol const char *  input,
const GPtrArray *  symbols
 

Compare a keyword to a list of valid symbols.

Take a symbol and translate it into its corresponding character as defined by the symbols array. The structure of the symbols array looks as follows:

 symbols[0] => "symbol1"
 symbols[1] => 'a'
 symbols[2] => "symbol2"
 symbols[3] => 'b'
 ...
where "symbol1" => 'a' and "symbol2" => 'b'.

  • input is the symbol to parse
  • symbols is the symbols array to check against
    Returns:
    the character corresponding to the given symbol

Definition at line 76 of file parse.c.

References lutil_streq().

char lutil_parse_parseSymbolArray const char *  input,
const char *  symbols[]
 

Compare a keyword to a list of valid symbols.

Like lutil_parse_parseSymbol but using a two dimensional array instead of a GPtrArray

  • input is the symbol to parse
  • symbols is the symbols array to check against
    Returns:
    the character corresponding to the given symbol
    See also:
    lutil_parse_parseSymbol

Definition at line 103 of file parse.c.

References lutil_streq().

Referenced by parseGenericInfo(), parseLibupdate(), and parseSoftware().

char* lutil_parse_skipString char *  input,
char *  string
 

Skip a string in the given line of input.

Simply returns a pointer that skips the first strlen(string) characters of input.

  • input is the line of input to skip over
  • string is the string to skip (must be at beginning of string to work properly)

Definition at line 259 of file parse.c.


Generated on Mon Apr 12 22:17:12 2004 for luau by doxygen 1.3.2