Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

Simplified File Parsing Method

IP.com Disclosure Number: IPCOM000116427D
Original Publication Date: 1995-Sep-01
Included in the Prior Art Database: 2005-Mar-30
Document File: 6 page(s) / 202K

Publishing Venue

IBM

Related People

Keller, SA: AUTHOR

Abstract

In the software industry profiles, or input data files are common. They provide some degree of setup or customization information. Many times these files are created in ASCII format so they are readable and can be created with any ASCII editor. The files usually contain some number of key words with associated values, or definitions. The problem is the files are relatively simple and don't require the all encompassing lexical analyzer and yacc.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 20% of the total text.

Simplified File Parsing Method

      In the software industry profiles, or input data files are
common.  They provide some degree of setup or customization
information.  Many times these files are created in ASCII format so
they are readable and can be created with any ASCII editor.  The
files usually contain some number of key words with associated
values, or definitions.  The problem is the files are relatively
simple and don't require the all encompassing lexical analyzer and
yacc.

      The solution to the problem was to have a simplified way of
defining key words to be searched for, and the processing to be done
upon finding the given key word.  The Simplified File Parsing Method
accomplishes this, resulting in decreased development time, yet
adding the robustness and object oriented nature of a library
routine.

      The Simplified File Parsing Method consists of three pieces.
The state table and state definitions, the parsing engine, and the
processing function.  Realize the level of implementation can be
varied based on project requirements.

      First, the state table and state definitions.  The state table
consists of a globally available structure which has an entry for
each key word required.  Additionally, each state must have a
definition (#define) representing it.  The following example shows
the state definitions required.  For this example the states
represent constant, event, and alarm definitions.
  /*
  ** State Definitions  -  These state defines correspond to the
index
  **                       into the state table array.  If the number
is
  **                       changed then the state table
initialization
  **                       must be changed too.
  */
  #define  CONST_STATE        0
  #define  EVENT_STATE        1
  #define  ALARM_STATE        2
  #define  NUM_OF_STATES      3
  /*
  ** The following definitions are not normal
  ** state machine...When adding a state
  ** processing routine the new state should be
  ** added prior to NUM_OF_STATES, and then adjust
  ** the definitions with numbers higher than that
  */
  #define  END_OF_FILE        3
  #define  LAST_STATE         4

      The state table definition consists of two structures: the
first defines the information required for each state, the other
defines a table of states, and some processing variables (see the
following example).  The state entry includes SectionStart and
SectionEnd for multiple line entries.  The current file line number
is stored in the SectionStart when the key word is found, when
another key word is found the current line number is stored in
SectionEnd.  The Keyword defines what character string the parser is
to search for, the StateFunc defines the function to be called when
the Keyword is found, and Data is available for the function to point
to a data...