Class: TaskJuggler::ProjectFileParser
- Inherits:
-
TextParser
- Object
- TextParser
- TaskJuggler::ProjectFileParser
- Includes:
- TjpSyntaxRules
- Defined in:
- lib/taskjuggler/ProjectFileParser.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from TextParser
Instance Method Summary collapse
-
#close ⇒ Object
Call this function to cleanup the parser structures after the file processing has been completed.
-
#initialize ⇒ ProjectFileParser
constructor
Create the parser object.
-
#nextToken ⇒ Object
This function will deliver the next token from the scanner.
-
#open(file, master, fileNameIsBuffer = false) ⇒ Object
Call this function with the master file to start processing a TJP file or a set of TJP files.
- #parseReportAttributes(report, attributes) ⇒ Object
-
#returnToken(token) ⇒ Object
This function can be used to return tokens.
-
#setGlobalMacros ⇒ Object
A set of standard marcros is defined in all files as soon as the project header has been read.
Methods included from TjpSyntaxRules
#rule_absoluteTaskId, #rule_account, #rule_accountAttributes, #rule_accountBody, #rule_accountCredit, #rule_accountCredits, #rule_accountHeader, #rule_accountId, #rule_accountReport, #rule_accountReportHeader, #rule_accountScenarioAttributes, #rule_aggregate, #rule_alertLevel, #rule_alertLevelDefinition, #rule_alertLevelDefinitions, #rule_allOrNone, #rule_allocate, #rule_allocateShiftAssignments, #rule_allocateShiftsAssignments, #rule_allocation, #rule_allocationAttributes, #rule_allocationBody, #rule_allocationHeader, #rule_allocationSelectionMode, #rule_allocations, #rule_argument, #rule_argumentList, #rule_argumentListBody, #rule_author, #rule_balance, #rule_balanceAccounts, #rule_bookingAttributes, #rule_bookingBody, #rule_calendarDuration, #rule_chargeMode, #rule_chargeSetItem, #rule_chargeset, #rule_chartScale, #rule_color, #rule_columnBody, #rule_columnDef, #rule_columnId, #rule_columnOptions, #rule_currencyFormat, #rule_date, #rule_dateCalcedOrNot, #rule_declareFlagList, #rule_details, #rule_durationUnit, #rule_durationUnitOrPercent, #rule_dynamicAttributes, #rule_export, #rule_exportAttributes, #rule_exportBody, #rule_exportFormat, #rule_exportFormats, #rule_exportHeader, #rule_extendAttributes, #rule_extendBody, #rule_extendId, #rule_extendOptions, #rule_extendOptionsBody, #rule_extendProperty, #rule_extendPropertyId, #rule_fail, #rule_flag, #rule_flagList, #rule_flagLogicalExpression, #rule_flagOperand, #rule_flagOperation, #rule_flagOperationChain, #rule_flagOperator, #rule_flagOperatorAndOperand, #rule_flags, #rule_formats, #rule_functionPatterns, #rule_functions, #rule_functionsBody, #rule_hAlignment, #rule_headline, #rule_hideaccount, #rule_hidejournalentry, #rule_hideresource, #rule_hidetask, #rule_iCalReport, #rule_iCalReportAttributes, #rule_iCalReportBody, #rule_iCalReportHeader, #rule_idOrAbsoluteId, #rule_includeAttributes, #rule_includeAttributesBody, #rule_includeFile, #rule_includeFileName, #rule_includeProperties, #rule_interval, #rule_intervalDuration, #rule_intervalEnd, #rule_intervalOptional, #rule_intervalOptionalEnd, #rule_intervalOrDate, #rule_intervals, #rule_intervalsOptional, #rule_journalEntry, #rule_journalEntryAttributes, #rule_journalEntryBody, #rule_journalEntryHeader, #rule_journalReportAttributes, #rule_journalReportMode, #rule_journalSortCriteria, #rule_journalSortCriterium, #rule_leafResourceId, #rule_leave, #rule_leaveAllowance, #rule_leaveAllowanceList, #rule_leaveAllowances, #rule_leaveList, #rule_leaveName, #rule_leaveType, #rule_leaves, #rule_limitAttributes, #rule_limitAttributesBody, #rule_limitValue, #rule_limits, #rule_limitsAttributes, #rule_limitsBody, #rule_limitsHeader, #rule_listOfDays, #rule_listOfTimes, #rule_listType, #rule_loadunit, #rule_loadunitName, #rule_logicalExpression, #rule_macro, #rule_moreAlternatives, #rule_moreArguments, #rule_moreBangs, #rule_moreChargeSetItems, #rule_moreColumnDef, #rule_moreDepTasks, #rule_moreExportFormats, #rule_moreJournalSortCriteria, #rule_moreListOfDays, #rule_moreOutputFormats, #rule_morePredTasks, #rule_moreProjectIDs, #rule_moreSortCriteria, #rule_moreTimeIntervals, #rule_navigator, #rule_navigatorAttributes, #rule_navigatorBody, #rule_navigatorHeader, #rule_nikuReport, #rule_nikuReportAttributes, #rule_nikuReportBody, #rule_nikuReportHeader, #rule_nodeId, #rule_nodeIdList, #rule_nonZeroWorkingDuration, #rule_number, #rule_numberFormat, #rule_operand, #rule_operation, #rule_operationChain, #rule_operator, #rule_operatorAndOperand, #rule_optionalID, #rule_optionalMinus, #rule_optionalPercent, #rule_optionalScenarioIdCol, #rule_optionalVersion, #rule_outputFormat, #rule_outputFormats, #rule_plusOrMinus, #rule_project, #rule_projectBody, #rule_projectBodyAttributes, #rule_projectBodyInclude, #rule_projectDeclaration, #rule_projectHeader, #rule_projectIDs, #rule_projectProlog, #rule_projectProperties, #rule_projectPropertiesBody, #rule_projection, #rule_projectionAttributes, #rule_prologInclude, #rule_properties, #rule_propertiesBody, #rule_propertiesFile, #rule_propertiesInclude, #rule_purge, #rule_referenceAttributes, #rule_referenceBody, #rule_relativeId, #rule_reportAttributes, #rule_reportBody, #rule_reportEnd, #rule_reportId, #rule_reportIdUnverifd, #rule_reportName, #rule_reportPeriod, #rule_reportProperties, #rule_reportPropertiesBody, #rule_reportPropertiesFile, #rule_reportStart, #rule_reportTitle, #rule_reportableAttributes, #rule_reports, #rule_resource, #rule_resourceAttributes, #rule_resourceBody, #rule_resourceBooking, #rule_resourceBookingHeader, #rule_resourceHeader, #rule_resourceId, #rule_resourceLeafList, #rule_resourceList, #rule_resourceReport, #rule_resourceReportHeader, #rule_resourceScenarioAttributes, #rule_resourceShiftAssignments, #rule_resourceShiftsAssignments, #rule_rollupaccount, #rule_rollupresource, #rule_rolluptask, #rule_scenario, #rule_scenarioAttributes, #rule_scenarioBody, #rule_scenarioHeader, #rule_scenarioId, #rule_scenarioIdCol, #rule_scenarioIdList, #rule_scenarioIdx, #rule_schedulingDirection, #rule_schedulingMode, #rule_shift, #rule_shiftAssignment, #rule_shiftAssignments, #rule_shiftAttributes, #rule_shiftBody, #rule_shiftHeader, #rule_shiftId, #rule_shiftScenarioAttributes, #rule_sortAccounts, #rule_sortAccountsKeyword, #rule_sortCriteria, #rule_sortCriterium, #rule_sortJournalEntries, #rule_sortNonTree, #rule_sortResources, #rule_sortResourcesKeyword, #rule_sortTasks, #rule_sortTasksKeyword, #rule_sortTree, #rule_ssReportAttributes, #rule_ssReportBody, #rule_ssReportHeader, #rule_ssStatus, #rule_ssStatusAttributes, #rule_ssStatusBody, #rule_ssStatusHeader, #rule_statusSheet, #rule_statusSheetAttributes, #rule_statusSheetBody, #rule_statusSheetFile, #rule_statusSheetHeader, #rule_statusSheetReport, #rule_statusSheetTask, #rule_statusSheetTaskAttributes, #rule_statusSheetTaskBody, #rule_statusSheetTaskHeader, #rule_subNodeId, #rule_summary, #rule_supplement, #rule_supplementAccount, #rule_supplementReport, #rule_supplementResource, #rule_supplementTask, #rule_tagfile, #rule_tagfileAttributes, #rule_tagfileBody, #rule_tagfileHeader, #rule_task, #rule_taskAttributes, #rule_taskBody, #rule_taskBooking, #rule_taskBookingHeader, #rule_taskDep, #rule_taskDepAttributes, #rule_taskDepBody, #rule_taskDepHeader, #rule_taskDepId, #rule_taskDepList, #rule_taskHeader, #rule_taskId, #rule_taskIdUnverifd, #rule_taskList, #rule_taskPeriod, #rule_taskPred, #rule_taskPredHeader, #rule_taskPredList, #rule_taskReport, #rule_taskReportHeader, #rule_taskScenarioAttributes, #rule_taskShiftAssignments, #rule_taskShiftsAssignments, #rule_textReport, #rule_textReportHeader, #rule_timeInterval, #rule_timeSheet, #rule_timeSheetAttributes, #rule_timeSheetBody, #rule_timeSheetFile, #rule_timeSheetHeader, #rule_timeSheetReport, #rule_timeformat, #rule_timezone, #rule_traceReport, #rule_traceReportHeader, #rule_tsNewTaskHeader, #rule_tsReportAttributes, #rule_tsReportBody, #rule_tsReportHeader, #rule_tsStatus, #rule_tsStatusAttributes, #rule_tsStatusBody, #rule_tsStatusHeader, #rule_tsTaskAttributes, #rule_tsTaskBody, #rule_tsTaskHeader, #rule_undefResourceId, #rule_vacationName, #rule_valDate, #rule_valInterval, #rule_valIntervalOrDate, #rule_valIntervals, #rule_validTimeZone, #rule_warn, #rule_weekDayInterval, #rule_weekDayIntervalEnd, #rule_weekday, #rule_workingDuration, #rule_workingDurationPercent, #rule_workinghours, #rule_workinghoursProject, #rule_workinghoursResource, #rule_workinghoursShift, #rule_yesNo
Methods inherited from TextParser
#error, #initRules, #limitTokenSet, #newRule, #optional, #parse, #pattern, #repeatable, #sourceFileInfo, #updateParserTables, #warning
Methods included from MessageHandler
#critical, #debug, #error, #fatal, #info, #warning
Constructor Details
#initialize ⇒ ProjectFileParser
Create the parser object.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/taskjuggler/ProjectFileParser.rb', line 35 def initialize super # 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 ] initRules updateParserTables @project = nil end |
Instance Method Details
#close ⇒ Object
Call this function to cleanup the parser structures after the file processing has been completed.
70 71 72 |
# File 'lib/taskjuggler/ProjectFileParser.rb', line 70 def close @scanner.close end |
#nextToken ⇒ Object
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.
77 78 79 |
# File 'lib/taskjuggler/ProjectFileParser.rb', line 77 def nextToken @scanner.nextToken end |
#open(file, master, fileNameIsBuffer = false) ⇒ Object
Call this function with the master file to start processing a TJP file or a set of TJP files.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/taskjuggler/ProjectFileParser.rb', line 51 def open(file, master, fileNameIsBuffer = false) @scanner = ProjectFileScanner.new(file) # 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') end @scanner.open(fileNameIsBuffer) @property = nil @scenarioIdx = 0 initFileStack # Stack for property IDs. Needed to handle nested 'supplement' # statements. @idStack = [] end |
#parseReportAttributes(report, attributes) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/taskjuggler/ProjectFileParser.rb', line 104 def parseReportAttributes(report, attributes) open(attributes, false, true) @property = report @project = report.project parse(:dynamicAttributes) end |
#returnToken(token) ⇒ Object
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.
85 86 87 |
# File 'lib/taskjuggler/ProjectFileParser.rb', line 85 def returnToken(token) @scanner.returnToken(token) end |
#setGlobalMacros ⇒ Object
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.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/taskjuggler/ProjectFileParser.rb', line 92 def setGlobalMacros @scanner.addMacro(Macro.new('projectstart', @project['start'].to_s, @scanner.sourceFileInfo)) @scanner.addMacro(Macro.new('projectend', @project['end'].to_s, @scanner.sourceFileInfo)) @scanner.addMacro(Macro.new('now', @project['now'].to_s, @scanner.sourceFileInfo)) @scanner.addMacro(Macro.new('today', @project['now']. to_s(@project['timeFormat']), @scanner.sourceFileInfo)) end |