class TaskJuggler::ProjectFileParser

This class specializes the TextParser class for use with TaskJuggler project files (TJP Files). The primary purpose is to provide functionality that make it more comfortable to define the TaskJuggler syntax in a form that is human creatable but also powerful enough to define the data structures the parser needs to understand the syntax.

By adding some additional information to the syntax rules, we can also generate the complete reference manual from this rule set.

Public Class Methods

new() click to toggle source

Create the parser object.

Calls superclass method
# File lib/taskjuggler/ProjectFileParser.rb, line 34
def initialize

  # Define the token types that the ProjectFileScanner may return for
  # variable elements.
  @variables = [ :INTEGER, :FLOAT, :DATE, :TIME, :STRING, :LITERAL,
                 :ID, :ID_WITH_COLON, :ABSOLUTE_ID, :MACRO ]


  @project = nil

Public Instance Methods

close() click to toggle source

Call this function to cleanup the parser structures after the file processing has been completed.

# File lib/taskjuggler/ProjectFileParser.rb, line 69
def close
nextToken() click to toggle source

This function will deliver the next token from the scanner. A token is a two element Array that contains the ID or type of the token as well as the text string of the token.

# File lib/taskjuggler/ProjectFileParser.rb, line 76
def nextToken
open(file, master, fileNameIsBuffer = false) click to toggle source

Call this function with the master file to start processing a TJP file or a set of TJP files.

# File lib/taskjuggler/ProjectFileParser.rb, line 50
def open(file, master, fileNameIsBuffer = false)
  @scanner =
  # We need the ProjectFileScanner object for error reporting.
  if master && !fileNameIsBuffer && file != '.' && file[-4, 4] != '.tjp'
    error('illegal_extension', "Project file name must end with " +
          '\.tjp\ extension')

  @property = nil
  @scenarioIdx = 0
  # Stack for property IDs. Needed to handle nested 'supplement'
  # statements.
  @idStack = []
parseReportAttributes(report, attributes) click to toggle source
# File lib/taskjuggler/ProjectFileParser.rb, line 103
def parseReportAttributes(report, attributes)
  open(attributes, false, true)
  @property = report
  @project = report.project
returnToken(token) click to toggle source

This function can be used to return tokens. Returned tokens will be pushed on a LIFO stack. To preserve the order of the original tokens the last token must be returned first. This mechanism is used to implement look-ahead functionality.

# File lib/taskjuggler/ProjectFileParser.rb, line 84
def returnToken(token)
setGlobalMacros() click to toggle source

A set of standard marcros is defined in all files as soon as the project header has been read. Calling this functions gets the values from @project and inserts the Macro objects into the ProjectFileScanner.

# File lib/taskjuggler/ProjectFileParser.rb, line 91
def setGlobalMacros
  @scanner.addMacro('projectstart', @project['start'].to_s,
  @scanner.addMacro('projectend', @project['end'].to_s,
  @scanner.addMacro('now', @project['now'].to_s,
  @scanner.addMacro('today', @project['now'].