Module: TaskJuggler::TjpSyntaxRules

Included in:
ProjectFileParser
Defined in:
lib/taskjuggler/TjpSyntaxRules.rb

Overview

This module contains the rule definition for the TJP syntax. Every rule is put in a function who’s name must start with rule_. The functions are not necessary but make the file more readable and receptable to syntax folding.

Instance Method Summary collapse

Instance Method Details

#rule_absoluteTaskIdObject



21
22
23
24
25
26
27
28
29
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 21

def rule_absoluteTaskId
  pattern(%w( !taskIdUnverifd ), lambda {
    id = (@taskprefix.empty? ? '' : @taskprefix + '.') + @val[0]
    if (task = @project.task(id)).nil?
      error('unknown_abs_task', "Unknown task #{id}", @sourceFileInfo[0])
    end
    task
  })
end

#rule_accountObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 31

def 
  pattern(%w( !accountHeader !accountBody ), lambda {
     @property = @property.parent
  })
  doc('account', <<'EOT'
Declares an account. Accounts can be used to calculate costs of tasks or the
whole project. Account declaration may be nested, but only leaf accounts may
be used to track turnover. When the cost of a task is split over multiple
accounts they all must have the same top-level group account. Top-level
accounts can be used for profit/loss calculations. The sub-account structure
of a top-level account should be organized accordingly.

Accounts have a global name space. All IDs must be unique within the accounts of the project.
EOT
     )
  example('Account', '1')
end

#rule_accountAttributesObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 49

def rule_accountAttributes
  repeatable
  optional
  pattern(%w( !account))
  pattern(%w( !accountScenarioAttributes ))
  pattern(%w( !scenarioIdCol !accountScenarioAttributes ), lambda {
    @scenarioIdx = 0
  })
  # Other attributes will be added automatically.
end

#rule_accountBodyObject



60
61
62
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 60

def rule_accountBody
  optionsRule('accountAttributes')
end

#rule_accountCreditObject



64
65
66
67
68
69
70
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 64

def rule_accountCredit
  pattern(%w( !valDate $STRING !number ), lambda {
    AccountCredit.new(@val[0], @val[1], @val[2])
  })
  arg(1, 'description', 'Short description of the transaction')
  arg(2, 'amount', 'Amount to be booked.')
end

#rule_accountCreditsObject



72
73
74
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 72

def rule_accountCredits
  listRule('moreAccountCredits', '!accountCredit')
end

#rule_accountHeaderObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 76

def rule_accountHeader
  pattern(%w( _account !optionalID $STRING ), lambda {
    if @property.nil? && !@accountprefix.empty?
      @property = @project.(@accountprefix)
    end
    if @val[1] && @project.(@val[1])
      error('account_exists', "Account #{@val[1]} has already been defined.",
            @sourceFileInfo[1], @property)
    end
    @property = Account.new(@project, @val[1], @val[2], @property)
    @property.sourceFileInfo = @sourceFileInfo[0]
    @property.inheritAttributes
    @scenarioIdx = 0
  })
  arg(2, 'name', 'A name or short description of the account')
end

#rule_accountIdObject



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 93

def rule_accountId
  pattern(%w( $ID ), lambda {
    id = @val[0]
    id = @accountprefix + '.' + id unless @accountprefix.empty?
    # In case we have a nested supplement, we need to prepend the parent ID.
    id = @property.fullId + '.' + id if @property && @property.is_a?(Account)
    if ( = @project.(id)).nil?
      error('unknown_account', "Unknown account #{id}", @sourceFileInfo[0])
    end
    
  })
end

#rule_accountReportObject



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 106

def rule_accountReport
  pattern(%w( !accountReportHeader !reportBody ), lambda {
    @property = @property.parent
  })
  level(:beta)
  doc('accountreport', <<'EOT'
The report lists accounts and their respective values in a table. The report
can operate in two modes:

# Balance mode: If a [[balance]] has been set, the report will include the
defined cost and revenue accounts as well as all their sub accounts. To reduce
the list of included accounts, you can use the [[hideaccount]],
[[rollupaccount]] or [[accountroot]] attributes. The order of the task can
be controlled with [[sortaccounts]]. If the first sorting criteria is tree
sorting, the parent accounts will always be included to form the tree.
Tree sorting is the default. You need to change it if you do not want certain
parent accounts to be included in the report. Additionally, it will contain a line at the end that lists the balance (revenue - cost).

# Normal mode: All reports are listed in the order and completeness as defined
by the other report attributes. No balance line will be included.
EOT
     )
  example('AccountReport')
end

#rule_accountReportHeaderObject



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 131

def rule_accountReportHeader
  pattern(%w( _accountreport !optionalID !reportName ), lambda {
    newReport(@val[1], @val[2], :accountreport, @sourceFileInfo[0]) do
      unless @property.modified?('columns')
        # Set the default columns for this report.
        %w( bsi name monthly ).each do |col|
          @property.get('columns') <<
          TableColumnDefinition.new(col, columnTitle(col))
        end
      end
      # Show all accounts, sorted by tree, seqno-up.
      unless @property.modified?('hideAccount')
        @property.set('hideAccount',
                      LogicalExpression.new(LogicalOperation.new(0)))
      end
      unless @property.modified?('sortAccounts')
        @property.set('sortAccounts',
                      [ [ 'tree', true, -1 ],
                        [ 'seqno', true, -1 ] ])
      end
    end
  })
end

#rule_accountScenarioAttributesObject



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 155

def rule_accountScenarioAttributes
  pattern(%w( _aggregate !aggregate ), lambda {
    @property.set('aggregate', @val[1])
  })
  doc('aggregate', <<'EOT'
Specifies whether the account is used to track task or resource specific
amounts. The default is to track tasks.
EOT
     )
  example('AccountReport')

  pattern(%w( _credits !accountCredits ), lambda {
    @property['credits', @scenarioIdx] += @val[1]
  })
  doc('credits', <<'EOT'
Book the specified amounts to the account at the specified date. The
desciptions are just used for documentary purposes.
EOT
     )
  example('Account', '1')

  pattern(%w( !flags ))
  doc('flags.account', <<'EOT'
Attach a set of flags. The flags can be used in logical expressions to filter
properties from the reports.
EOT
     )

  # Other attributes will be added automatically.
end

#rule_aggregateObject



186
187
188
189
190
191
192
193
194
195
196
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 186

def rule_aggregate
  pattern(%w( _resources ), lambda {
    :resources
  })
  descr('Aggregate resources')

  pattern(%w( _tasks ), lambda {
    :tasks
  })
  descr('Aggregate tasks')
end

#rule_alertLevelObject



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 198

def rule_alertLevel
  pattern(%w( $ID ), lambda {
    level = @project['alertLevels'].indexById(@val[0])
    unless level
      levels = @project['alertLevels'].map { |l| l.id }
      error('bad_alert', "Unknown alert level #{@val[0]}. Must be " +
            "one of #{levels.join(', ')}", @sourceFileInfo[0])
    end
    level
  })
  arg(0, 'alert level', <<'EOT'
By default supported values are ''''green'''', ''''yellow'''' and ''''red''''.
The default value is ''''green''''. You can define your own levels with
[[alertlevels]].
EOT
     )
end

#rule_alertLevelDefinitionObject



216
217
218
219
220
221
222
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 216

def rule_alertLevelDefinition
  pattern(%w( $ID $STRING !color ), lambda {
    [ @val[0], @val[1], @val[2] ]
  })
  arg(0, 'ID', "A unique ID for the alert level")
  arg(1, 'color name', 'A unique name of the alert level color')
end

#rule_alertLevelDefinitionsObject



224
225
226
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 224

def rule_alertLevelDefinitions
  listRule('moreAlertLevelDefinitions', '!alertLevelDefinition')
end

#rule_allocateObject



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 228

def rule_allocate
  pattern(%w( _allocate !allocations ), lambda {
    checkContainer('allocate')
    @property['allocate', @scenarioIdx] += @val[1]
  })
  doc('allocate', <<'EOT'
Specify which resources should be allocated to the task. The
attributes provide numerous ways to control which resource is used and when
exactly it will be assigned to the task. Shifts and limits can be used to
restrict the allocation to certain time intervals or to limit them to a
certain maximum per time period. The purge statement can be used to remove
inherited allocations or flags.

For effort-based tasks the task duration is clipped to only extend from the
beginning of the first allocation to the end of the last allocation. This is
done to optimize for an overall minimum project duration as dependent tasks
can potentially use the unallocated, clipped slots.
EOT
     )
  example('Allocate-1', '1')
end

#rule_allocateShiftAssignmentsObject



403
404
405
406
407
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 403

def rule_allocateShiftAssignments
  pattern(%w( _shift ), lambda {
    @shiftAssignments = @allocate.shifts
  })
end

#rule_allocateShiftsAssignmentsObject



409
410
411
412
413
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 409

def rule_allocateShiftsAssignments
  pattern(%w( _shifts ), lambda {
    @shiftAssignments = @allocate.shifts
  })
end

#rule_allocationObject



250
251
252
253
254
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 250

def rule_allocation
  pattern(%w( !allocationHeader !allocationBody ), lambda {
    @val[0]
  })
end

#rule_allocationAttributesObject



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 256

def rule_allocationAttributes
  optional
  repeatable

  pattern(%w( _alternative !resourceId !moreAlternatives ), lambda {
    ([ @val[1] ] + (@val[2] ? @val[2] : [])).each do |candidate|
      @allocate.addCandidate(candidate)
    end
  })
  doc('alternative', <<'EOT'
Specify which resources should be allocated to the task. The optional
attributes provide numerous ways to control which resource is used and when
exactly it will be assigned to the task. Shifts and limits can be used to
restrict the allocation to certain time intervals or to limit them to a
certain maximum per time period.
EOT
     )
  example('Alternative', '1')

  pattern(%w( !limits ), lambda {
    limits = @property['limits', @scenarioIdx] = @val[0]
    @allocate.candidates.each do |resource|
       limits.limits.each do |l|
         l.resource = resource if resource.leaf?
       end
    end
  })
  level(:removed)
  doc('limits.allocate', '')

  pattern(%w( _select !allocationSelectionMode ), lambda {
    @allocate.setSelectionMode(@val[1])
  })
  doc('select', <<'EOT'
The select function controls which resource is picked from an allocation and
it's alternatives. The selection is re-evaluated each time the resource used
in the previous time slot becomes unavailable.

Even for non-persistent allocations a change in the resource selection only
happens if the resource used in the previous (or next for ASAP tasks) time
slot has become unavailable.
EOT
     )

  pattern(%w( _persistent ), lambda {
    @allocate.persistent = true
  })
  doc('persistent', <<'EOT'
Specifies that once a resource is picked from the list of alternatives, this
resource is used for the whole task. This is useful when several alternative
resources have been specified. Normally the selected resource can change after
each break. A break is an interval of at least one timeslot where no resources
were available.
EOT
     )

  pattern(%w( _mandatory ), lambda {
    @allocate.mandatory = true
  })
  doc('mandatory', <<'EOT'
Makes a resource allocation mandatory. This means, that for each time slot
only then resources are allocated when all mandatory resources are available.
So either all mandatory resources can be allocated for the time slot, or no
resource will be allocated.
EOT
     )
  pattern(%w( !allocateShiftAssignments !shiftAssignment ), lambda {
    begin
      @allocate.shifts = @shiftAssignments
    rescue AttributeOverwrite
      # Multiple shift assignments are a common idiom, so don't warn about
      # them.
    end
    @shiftAssignments = nil
  })
  level(:deprecated)
  also('shifts.allocate')
  doc('shift.allocate', <<'EOT'
Limits the allocations of resources during the specified interval to the
specified shift. Multiple shifts can be defined, but shift intervals may not
overlap. Allocation shifts are an additional restriction to the
[[shifts.task|task shifts]] and [[shifts.resource|resource shifts]] or
[[workinghours.resource|resource working hours]]. Allocations will only be
made for time slots that are specified as duty time in all relevant shifts.
The restriction to the shift is only active during the specified time
interval. Outside of this interval, no restrictions apply.
EOT
     )

  pattern(%w( !allocateShiftsAssignments !shiftAssignments ), lambda {
    begin
      @allocate.shifts = @shiftAssignments
    rescue AttributeOverwrite
      # Multiple shift assignments are a common idiom, so don't warn about
      # them.
    end
    @shiftAssignments = nil
  })
  doc('shifts.allocate', <<'EOT'
Limits the allocations of resources during the specified interval to the
specified shift. Multiple shifts can be defined, but shift intervals may not
overlap. Allocation shifts are an additional restriction to the
[[shifts.task|task shifts]] and [[shifts.resource|resource shifts]] or
[[workinghours.resource|resource working hours]]. Allocations will only be
made for time slots that are specified as duty time in all relevant shifts.
The restriction to the shift is only active during the specified time
interval. Outside of this interval, no restrictions apply.
EOT
     )
end

#rule_allocationBodyObject



367
368
369
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 367

def rule_allocationBody
  optionsRule('allocationAttributes')
end

#rule_allocationHeaderObject



371
372
373
374
375
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 371

def rule_allocationHeader
  pattern(%w( !resourceId ), lambda {
    @allocate = Allocation.new([ @val[0] ])
  })
end

#rule_allocationsObject



377
378
379
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 377

def rule_allocations
  listRule('moreAllocations', '!allocation')
end

#rule_allocationSelectionModeObject



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 381

def rule_allocationSelectionMode
  singlePattern('_maxloaded')
  descr('Pick the available resource that has been used the most so far.')

  singlePattern('_minloaded')
  descr('Pick the available resource that has been used the least so far.')

  singlePattern('_minallocated')
  descr(<<'EOT'
Pick the resource that has the smallest allocation factor. The
allocation factor is calculated from the various allocations of the resource
across the tasks. This is the default setting.
EOT
       )

  singlePattern('_order')
  descr('Pick the first available resource from the list.')

  singlePattern('_random')
  descr('Pick a random resource from the list.')
end

#rule_allOrNoneObject



415
416
417
418
419
420
421
422
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 415

def rule_allOrNone
  pattern(%w( _all ), lambda {
    1
  })
  pattern(%w( _none ), lambda {
    0
  })
end

#rule_argumentObject



424
425
426
427
428
429
430
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 424

def rule_argument
  singlePattern('$ABSOLUTE_ID')
  singlePattern('!date')
  singlePattern('$ID')
  singlePattern('$INTEGER')
  singlePattern('$FLOAT')
end

#rule_argumentListObject



432
433
434
435
436
437
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 432

def rule_argumentList
  optional
  pattern(%w( _( !argumentListBody _) ), lambda {
    @val[1].nil? ? [] : @val[1]
  })
end

#rule_argumentListBodyObject



439
440
441
442
443
444
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 439

def rule_argumentListBody
  optional
  pattern(%w( !argument !moreArguments ), lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_authorObject



446
447
448
449
450
451
452
453
454
455
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 446

def rule_author
  pattern(%w( _author !resourceId ), lambda {
    @journalEntry.author = @val[1]
  })
  doc('author', <<'EOT'
This attribute can be used to capture the authorship or source of the
information.
EOT
     )
end

#rule_balanceObject



457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 457

def rule_balance
  pattern(%w( _balance !balanceAccounts ), lambda {
    @val[1]
  })
  doc('balance', <<'EOT'
During report generation, TaskJuggler can consider some accounts to be revenue accounts, while other can be considered cost accounts. By using the balance attribute, two top-level accounts can be designated for a profit-loss-analysis. This analysis includes all sub accounts of these two top-level accounts.

To clear a previously set balance, just use a ''''-''''.
EOT
     )
  example('AccountReport')
end

#rule_balanceAccountsObject



470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 470

def rule_balanceAccounts
  pattern(%w( !accountId !accountId ), lambda {
    if @val[0].parent
      error('cost_acct_no_top',
            "The cost account #{@val[0].fullId} is not a top-level account.",
            @sourceFileInfo[0])
    end
    if @val[1].parent
      error('rev_acct_no_top',
            "The revenue account #{@val[1].fullId} is not a top-level " +
            "account.", @sourceFileInfo[1])
    end
    if @val[0] == @val[1]
      error('cost_rev_same',
            'The cost and revenue accounts may not be the same.',
            @sourceFileInfo[0])
    end
    [ @val[0], @val[1] ]
  })
  arg(0, 'cost account', <<'EOT'
The top-level account that is used for all cost related charges.
EOT
     )
  arg(2, 'revenue account', <<'EOT'
The top-level account that is used for all revenue related charges.
EOT
     )

  pattern([ '_-' ], lambda {
    [ nil, nil ]
  })
end

#rule_bookingAttributesObject



503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 503

def rule_bookingAttributes
  optional
  repeatable

  pattern(%w( _overtime $INTEGER ), lambda {
    if @val[1] < 0 || @val[1] > 2
      error('overtime_range',
            "Overtime value #{@val[1]} out of range (0 - 2).",
            @sourceFileInfo[1], @property)
    end
    @booking.overtime = @val[1]
  })
  doc('overtime.booking', <<'EOT'
This attribute enables bookings during off-hours and leaves. It implicitly
sets the [[sloppy.booking|sloppy]] attribute accordingly.
EOT
     )
  arg(1, 'value', <<'EOT'
* '''0''': You can only book available working time. (Default)

* '''1''': You can book off-hours as well.

* '''2''': You can book working time, off-hours and vacation time.
EOT
     )

  pattern(%w( _sloppy $INTEGER ), lambda {
    if @val[1] < 0 || @val[1] > 2
      error('sloppy_range',
            "Sloppyness value #{@val[1]} out of range (0 - 2).",
            @sourceFileInfo[1], @property)
    end
    @booking.sloppy = @val[1]
  })
  doc('sloppy.booking', <<'EOT'
Controls how strict TaskJuggler checks booking intervals for conflicts with
working periods and leaves. This attribute only affects the check for
conflicts. No assignments will be made unless the [[overtime.booking|
overtime]] attribute is set accordingly.
EOT
     )
  arg(1, 'sloppyness', <<'EOT'
* '''0''': Period may not contain any off-duty hours, vacation or other task
assignments. (default)

* '''1''': Period may contain off-duty hours, but no vacation time or other
task assignments.

* '''2''': Period may contain off-duty hours and vacation time, but no other
task assignments.
EOT
     )
end

#rule_bookingBodyObject



557
558
559
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 557

def rule_bookingBody
  optionsRule('bookingAttributes')
end

#rule_calendarDurationObject



561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 561

def rule_calendarDuration
  pattern(%w( !number !durationUnit ), lambda {
    convFactors = [ 60.0, # minutes
                    60.0 * 60, # hours
                    60.0 * 60 * 24, # days
                    60.0 * 60 * 24 * 7, # weeks
                    60.0 * 60 * 24 * 30.4167, # months
                    60.0 * 60 * 24 * 365 # years
                   ]
    ((@val[0] * convFactors[@val[1]]) / @project['scheduleGranularity']).to_i
  })
  arg(0, 'value', 'A floating point or integer number')
end

#rule_chargeModeObject



614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 614

def rule_chargeMode
  singlePattern('_onstart')
  descr('Charge the amount on starting the task.')

  singlePattern('_onend')
  descr('Charge the amount on finishing the task.')

  singlePattern('_perhour')
  descr('Charge the amount for every hour the task lasts.')

  singlePattern('_perday')
  descr('Charge the amount for every day the task lasts.')

  singlePattern('_perweek')
  descr('Charge the amount for every week the task lasts.')
end

#rule_chargesetObject



575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 575

def rule_chargeset
  pattern(%w( _chargeset !chargeSetItem !moreChargeSetItems ), lambda {
    checkContainer('chargeset')
    items = [ @val[1] ]
    items += @val[2] if @val[2]
    chargeSet = ChargeSet.new
    begin
      items.each do |item|
        chargeSet.addAccount(item[0], item[1])
      end
      chargeSet.complete
    rescue TjException
      error('chargeset', $!.message, @sourceFileInfo[0], @property)
    end
    masterAccounts = []
    @property['chargeset', @scenarioIdx].each do |set|
      masterAccounts << set.master
    end
    if masterAccounts.include?(chargeSet.master)
      error('chargeset_master',
            "All charge sets for this property must have different " +
            "top-level accounts.", @sourceFileInfo[0], @property)
    end
    @property['chargeset', @scenarioIdx] =
      @property['chargeset', @scenarioIdx] + [ chargeSet ]
  })
  doc('chargeset', <<'EOT'
A chargeset defines how the turnover associated with the property will be
charged to one or more accounts. A property may have any number of charge sets,
but each chargeset must deal with a different top-level account. A charge set
consists of one or more accounts. Each account must be a leaf account. The
account ID may be followed by a percentage value that determines the share for
this account. The total percentage of all accounts must be exactly 100%. If
some accounts don't have a percentage specification, the remainder to 100% is
distributed evenly between them.
EOT
     )
end

#rule_chargeSetItemObject



631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 631

def rule_chargeSetItem
  pattern(%w( !accountId !optionalPercent ), lambda {
    if @property.is_a?(Task)
      aggregate = :tasks
    elsif @property.is_a?(Resource)
      aggregate = :resources
    else
      raise "Unknown property type #{@property.class}"
    end

    if @val[0].get('aggregate') != aggregate
      error('account_bad_aggregate',
            "The account #{@val[0].fullId} cannot aggregate amounts " +
            "related to #{aggregate}.")
    end

    [ @val[0], @val[1] ]
  })
  arg(0, 'account', 'The ID of a previously defined leaf account.')
  arg(1, 'share', 'A percentage between 0 and 100%')
end

#rule_chartScaleObject



653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 653

def rule_chartScale
  singlePattern('_hour')
  descr('Set chart resolution to 1 hour.')

  singlePattern('_day')
  descr('Set chart resolution to 1 day.')

  singlePattern('_week')
  descr('Set chart resolution to 1 week.')

  singlePattern('_month')
  descr('Set chart resolution to 1 month.')

  singlePattern('_quarter')
  descr('Set chart resolution to 1 quarter.')

  singlePattern('_year')
  descr('Set chart resolution to 1 year.')
end

#rule_colorObject



673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 673

def rule_color
  pattern(%w( $STRING ), lambda {
    col = @val[0]
    unless /#[0-9A-Fa-f]{3}/ =~ col || /#[0-9A-Fa-f]{3}/ =~ col
      error('bad_color',
            "Color values must be specified as '#RGB' or '#RRGGBB' values",
            @sourceFileInfo[0])
    end
    col
  })
  arg(0, 'color', <<'EOT'
The RGB color values of the color. The following formats are supported: #RGB
and #RRGGBB. Where R, G, B are hexadecimal values. See
[http://en.wikipedia.org/wiki/Web_colors Wikipedia] for more details.
EOT
     )
end

#rule_columnBodyObject



691
692
693
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 691

def rule_columnBody
  optionsRule('columnOptions')
end

#rule_columnDefObject



695
696
697
698
699
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 695

def rule_columnDef
  pattern(%w( !columnId !columnBody ), lambda {
    @val[0]
  })
end

#rule_columnIdObject



701
702
703
704
705
706
707
708
709
710
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 701

def rule_columnId
  pattern(%w( !reportableAttributes ), lambda {
    @column = TableColumnDefinition.new(@val[0], columnTitle(@val[0]))
  })
  doc('columnid', <<'EOT'
This is a comprehensive list of all pre-defined [[columns]]. In addition to
the listed IDs all user defined attributes can be used as column IDs.
EOT
     )
end

#rule_columnOptionsObject



712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 712

def rule_columnOptions
  optional
  repeatable

  pattern(%w( _celltext !logicalExpression $STRING ), lambda {
    @column.cellText.addPattern(
      CellSettingPattern.new(newRichText(@val[2], @sourceFileInfo[2]),
                             @val[1]))
  })
  doc('celltext.column', <<'EOT'
Specifies an alternative content that is used for the cells of the column.
Usually such a text contains a query function. Otherwise all cells of the
column will have the same fixed value. The logical expression specifies for
which cells the text should be used. If multiple celltext patterns are
provided for a column, the first matching one is taken for each cell.
EOT
      )
  arg(2, 'text',
      'Alterntive cell text specified as [[Rich_Text_Attributes|Rich Text]]')

  pattern(%w( _cellcolor !logicalExpression !color ), lambda {
    @column.cellColor.addPattern(
      CellSettingPattern.new(@val[2], @val[1]))
  })
  doc('cellcolor.column', <<'EOT'
Specifies an alternative background color for the cells of this column. The
[[logicalexpression|logical expression]] specifies for which cells the color
should be used. If multiple cellcolor patterns are provided for a column, the
first matching one is used for each cell.
EOT
     )

  pattern(%w( _end !date ), lambda {
    @column.end = @val[1]
  })
  doc('end.column', <<'EOT'
Normally, columns with calculated values take the specified report period into
account when calculating their values. With this attribute, the user can
specify an end date for the period that should be used when calculating the
values of this column. It does not have an impact on columns with time
invariant values.
EOT
     )

  pattern(%w( _fontcolor !logicalExpression !color ), lambda {
    @column.fontColor.addPattern(
      CellSettingPattern.new(@val[2], @val[1]))
  })
  doc('fontcolor.column', <<'EOT'
Specifies an alternative font color for the cells of this column. The
[[logicalexpression|logical expression]] specifies for which cells the color
should be used. If multiple fontcolor patterns are provided for a column, the
first matching one is used for each cell.
EOT
     )

  pattern(%w( _halign !logicalExpression !hAlignment ), lambda {
    @column.hAlign.addPattern(
      CellSettingPattern.new(@val[2], @val[1]))
  })
  doc('halign.column', <<'EOT'
Specifies the horizontal alignment of the cell content. The
[[logicalexpression|logical expression]] specifies for which cells the alignment
setting should be used. If multiple halign patterns are provided for a column,
the first matching one is used for each cell.
EOT
     )

  pattern(%w( _listitem $STRING ), lambda {
    @column.listItem = @val[1]
  })
  doc('listitem.column', <<'EOT'
Specifies a [[Rich_Text_Attributes|Rich Text]] pattern that is used to generate the text for the list
items. The pattern should contain at least one ''''<nowiki><</nowiki>-query
attribute='XXX'->'''' element that will be replaced with the value of
attribute XXX. For the replacement, the property of the query will be the list
item.
EOT
     )

  pattern(%w( _listtype !listType ), lambda {
    @column.listType = @val[1]
  })
  also(%w( listitem.column ))
  doc('listtype.column', <<'EOT'
Specifies what type of list should be used. This attribute only affects
columns that contain a list of items.
EOT
     )

  pattern(%w( _period !interval ), lambda {
    @column.start = @val[1].start
    @column.end = @val[1].end
  })
  doc('period.column', <<'EOT'
This property is a shortcut for setting the [[start.column|start]] and
[[end.column|end]] property at the same time.
EOT
     )

  pattern(%w( _scale !chartScale ), lambda {
    @column.scale = @val[1]
  })
  doc('scale.column', <<'EOT'
Specifies the scale that should be used for a chart column. This value is ignored for all other columns.
EOT
     )

  pattern(%w( _start !date ), lambda {
    @column.start = @val[1]
  })
  doc('start.column', <<'EOT'
Normally, columns with calculated values take the specified report period into
account when calculating their values. With this attribute, the user can
specify a start date for the period that should be used when calculating the
values of this column. It does not have an impact on columns with time
invariant values.
EOT
     )

  pattern(%w( _timeformat1 $STRING ), lambda {
    @column.timeformat1 = @val[1]
  })
  doc('timeformat1', <<'EOT'
Specify an alternative format for the upper header line of calendar or Gantt
chart columns.
EOT
     )
  arg(1, 'format', 'See [[timeformat]] for details.')

  pattern(%w( _timeformat2 $STRING ), lambda {
    @column.timeformat2 = @val[1]
  })
  doc('timeformat2', <<'EOT'
Specify an alternative format for the lower header line of calendar or Gantt
chart columns.
EOT
     )
  arg(1, 'format', 'See [[timeformat]] for details.')

  pattern(%w( _title $STRING ), lambda {
    @column.title = @val[1]
  })
  doc('title.column', <<'EOT'
Specifies an alternative title for a report column.
EOT
     )
  arg(1, 'text', 'The new column title.')

  pattern(%w( _tooltip !logicalExpression $STRING ), lambda {
    @column.tooltip.addPattern(
      CellSettingPattern.new(newRichText(@val[2], @sourceFileInfo[2]),
                             @val[1]))
  })
  doc('tooltip.column', <<'EOT'
Specifies an alternative content for the tooltip. This will replace the
original content of the tooltip that would be available for columns with text
that does not fit the column with.  The [[logicalexpression|logical expression]]
specifies for which cells the text should be used. If multiple tooltip
patterns are provided for a column, the first matching one is taken for each
cell.
EOT
     )
  arg(2, 'text', <<'EOT'
The content of the tooltip. The text is interpreted as [[Rich_Text_Attributes|
Rich Text]].
EOT
     )

  pattern(%w( _width !number ), lambda {
    @column.width = @val[1]
  })
  doc('width.column', <<'EOT'
Specifies the maximum width of the column in screen pixels. If the content of
the column does not fit into this width, it will be cut off. In some cases a
scrollbar is added or a tooltip window with the complete content is shown when
the mouse is moved over the column. The latter is only supported in
interactive output formats. The resulting column width may be smaller if the
column has a fixed width (e. g. the chart column).
EOT
     )
end

#rule_currencyFormatObject



895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 895

def rule_currencyFormat
  pattern(%w( _currencyformat $STRING $STRING $STRING $STRING $INTEGER ),
      lambda {
    RealFormat.new(@val.slice(1, 5))
  })
  doc('currencyformat',
      'These values specify the default format used for all currency ' +
      'values.')
  example('Currencyformat')
  arg(1, 'negativeprefix', 'Prefix for negative numbers')
  arg(2, 'negativesuffix', 'Suffix for negative numbers')
  arg(3, 'thousandsep', 'Separator used for every 3rd digit')
  arg(4, 'fractionsep', 'Separator used to separate the fraction digits')
  arg(5, 'fractiondigits', 'Number of fraction digits to show')
end

#rule_dateObject



911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 911

def rule_date
  pattern(%w( !dateCalcedOrNot ), lambda {
    resolution = @project.nil? ? Project.maxScheduleGranularity :
                                 @project['scheduleGranularity']
    if @val[0] % resolution != 0
      error('misaligned_date',
            "The date must be aligned to the timing resolution (" +
            "#{resolution / 60} min) of the project.",
            @sourceFileInfo[0])
    end
    @val[0]
  })
  doc('date', <<'EOT'
A DATE is date and time specification similar to the ISO 8601 date format.
Instead of the hard to read ISO notation with a ''''T'''' between the date and
time sections, we simply use the more intuitive and easier to read dash:
''''<nowiki>YYYY-MM-DD[-hh:mm[:ss]][-TIMEZONE]</nowiki>''''. Hour, minutes,
seconds, and the ''''TIMEZONE'''' are optional. If not specified, the values
are set to 0.  ''''TIMEZONE'''' must be an offset to GMT or UTC, specified as
''''+HHMM'''' or ''''-HHMM''''. Dates must always be aligned with the
[[timingresolution]].

TaskJuggler also supports simple date calculations. You can add or subtract a
given interval from a fixed date.

 %{2009-11-01 + 8m}

This will result in an actual date of around 2010-07-01. Keep in mind that due
to the varying lengths of months TaskJuggler cannot add exactly 8 calendar
months. The date calculation functionality makes most sense when used with
macros.

 %{${now} - 2w}

This results in a date 2 weeks earlier than the current (or specified) date.
See [[duration]] for a complete list of supported time intervals. Don't forget
to put at least one space character after the date to prevent TaskJuggler from
interpreting the interval as an hour.

Date attributes may be invalid in some cases. This needs special care in
[[logicalexpression|logical expressions]].
EOT
     )
end

#rule_dateCalcedOrNotObject



956
957
958
959
960
961
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 956

def rule_dateCalcedOrNot
  singlePattern('$DATE')
  pattern(%w( _% _{ $DATE !plusOrMinus !intervalDuration _} ), lambda {
    @val[2] + ((@val[3] == '+' ? 1 : -1) * @val[4])
  })
end

#rule_declareFlagListObject



963
964
965
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 963

def rule_declareFlagList
  listRule('moreDeclareFlagList', '$ID')
end

#rule_detailsObject



967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 967

def rule_details
  pattern(%w( _details $STRING ), lambda {
    return if @val[1].empty?

    rtTokenSetMore =
      [ :LINEBREAK, :SPACE, :WORD, :BOLD, :ITALIC, :CODE, :BOLDITALIC,
        :PRE, :HREF, :HREFEND, :REF, :REFEND, :HLINE, :TITLE2, :TITLE3,
        :TITLE4, :TITLE2END, :TITLE3END, :TITLE4END,
        :BULLET1, :BULLET2, :BULLET3, :BULLET4, :NUMBER1, :NUMBER2, :NUMBER3,
        :NUMBER4 ]
    if @val[1] == "Some more details\n"
      error('ts_default_details',
            "'Some more details' is not a valid value",
            @sourceFileInfo[1])
    end
    @journalEntry.details = newRichText(@val[1], @sourceFileInfo[1],
                                        rtTokenSetMore)
  })
  doc('details', <<'EOT'
This is a continuation of the [[summary]] of the journal or status entry. It
can be several paragraphs long.
EOT
     )
  arg(1, 'text', <<'EOT'
The text will be interpreted as [[Rich_Text_Attributes|Rich Text]]. Only a
subset of the markup is supported for this attribute. You can use word
formatting, paragraphs, hyperlinks, lists, section and subsection
headers.
EOT
     )
end

#rule_durationUnitObject



999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 999

def rule_durationUnit
  pattern(%w( _min ), lambda { 0 })
  descr('minutes')

  pattern(%w( _h ), lambda { 1 })
  descr('hours')

  pattern(%w( _d ), lambda { 2 })
  descr('days')

  pattern(%w( _w ), lambda { 3 })
  descr('weeks')

  pattern(%w( _m ), lambda { 4 })
  descr('months')

  pattern(%w( _y ), lambda { 5 })
  descr('years')
end

#rule_durationUnitOrPercentObject



1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1019

def rule_durationUnitOrPercent
  pattern(%w( _% ), lambda { -1 })
  descr('percentage of reported period')

  pattern(%w( _min ), lambda { 0 })
  descr('minutes')

  pattern(%w( _h ), lambda { 1 })
  descr('hours')

  pattern(%w( _d ), lambda { 2 })
  descr('days')
end

#rule_dynamicAttributesObject



1033
1034
1035
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1033

def rule_dynamicAttributes
  pattern(%w( !reportAttributes . ))
end

#rule_exportObject



1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1037

def rule_export
  pattern(%w( !exportHeader !exportBody ), lambda {
    @property = @property.parent
  })
  doc('export', <<'EOT'
The export report looks like a regular TaskJuggler file with the provided
input data complemented by the results of the scheduling process. The content
of the report can be controlled with the [[definitions]] attribute. In case
the file contains the project header, a ''''.tjp'''' extension is added to the
file name. Otherwise, a ''''.tji'''' extension is used.

The [[resourceattributes]] and [[taskattributes]] attributes provide even more
control over the content of the file.

The export report can be used to share certain tasks or milestones with other
projects or to save past resource allocations as immutable part for future
scheduling runs. When an export report is included the project IDs of the
included tasks must be declared first with the project id property.
EOT
     )
  example('Export')
end

#rule_exportAttributesObject



1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1060

def rule_exportAttributes
  optional
  repeatable

  pattern(%w( _definitions !exportDefinitions ), lambda {
    @property.set('definitions', @val[1])
  })
  doc('definitions', <<"EOT"
This attribute controls what definitions will be contained in the report. If
the list includes ''project'', the generated file will have a ''''.tjp''''
extension. Otherwise it will have a ''''.tji'''' extension.

By default, the report contains everything and the generated files have a ''''.tjp'''' extension.
EOT
     )
  allOrNothingListRule('exportDefinitions',
                       { 'flags' => 'Include flag definitions',
                         'project' => 'Include project header',
                         'projecids' => 'Include project IDs',
                         'tasks' => 'Include task definitions',
                         'resources' => 'Include resource definitions' })

  pattern(%w( _formats !exportFormats ), lambda {
    @property.set('formats', @val[1])
  })
  level(:beta)
  doc('formats.export', <<'EOT'
This attribute defines for which output formats the export report should be
generated. By default, the TJP format will be used.
EOT
     )

  pattern(%w( !hideresource ))
  pattern(%w( !hidetask ))

  pattern(%w( !loadunit ))

  pattern(%w( !purge ))
  pattern(%w( !reportEnd ))
  pattern(%w( !reportPeriod ))
  pattern(%w( !reports ))
  pattern(%w( !reportStart ))

  pattern(%w( _resourceattributes !exportableResourceAttributes ), lambda {
    @property.set('resourceAttributes', @val[1])
  })
  doc('resourceattributes', <<"EOT"
Define a list of resource attributes that should be included in the report.
EOT
     )
  allOrNothingListRule('exportableResourceAttributes',
                       { 'booking' => 'Include bookings',
                         'leaves' => 'Include leaves',
                         'workinghours' => 'Include working hours' })

  pattern(%w( !rollupresource ))
  pattern(%w( !rolluptask ))

  pattern(%w( _scenarios !scenarioIdList ), lambda {
    # Don't include disabled scenarios in the report
    @val[1].delete_if { |sc| !@project.scenario(sc).get('active') }
    @property.set('scenarios', @val[1])
  })
  doc('scenarios.export', <<'EOT'
List of scenarios that should be included in the report. By default, all
scenarios will be included. This attribute can be used to limit the included
scenarios to a defined list.
EOT
     )

  pattern(%w( _taskattributes !exportableTaskAttributes ), lambda {
    @property.set('taskAttributes', @val[1])
  })
  doc('taskattributes', <<"EOT"
Define a list of task attributes that should be included in the report.
EOT
     )
  allOrNothingListRule('exportableTaskAttributes',
                       { 'booking' => 'Include bookings',
                         'complete' => 'Include completion values',
                         'depends' => 'Include dependencies',
                         'flags' => 'Include flags',
                         'maxend' => 'Include maximum end dates',
                         'maxstart' => 'Include maximum start dates',
                         'minend' =>  'Include minimum end dates',
                         'minstart' => 'Include minimum start dates',
                         'note' => 'Include notes',
                         'priority' => 'Include priorities',
                         'responsible' => 'Include responsible resource' })

  pattern(%w( _taskroot !taskId), lambda {
    if @val[1].leaf?
      error('taskroot_leaf',
            "#{@val[1].fullId} is not a container task",
            @sourceFileInfo[1])
    end
    @property.set('taskroot', @val[1])
  })
  level(:experimental)
  doc('taskroot.export', <<'EOT'
Only tasks below the specified root-level tasks are exported. The exported
tasks will have the ID of the root-level task stripped from their ID, so that
the sub-tasks of the root-level task become top-level tasks in the report
file.
EOT
     )
  example('TaskRoot')

  pattern(%w( _timezone !validTimeZone ), lambda {
    @property.set('timezone', @val[1])
  })
  doc('timezone.export',
      "Set the time zone to be used for all dates in the report.")
end

#rule_exportBodyObject



1175
1176
1177
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1175

def rule_exportBody
  optionsRule('exportAttributes')
end

#rule_exportFormatObject



1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1179

def rule_exportFormat
  pattern(%w( _tjp ), lambda {
    :tjp
  })
  descr('Export of the scheduled project in TJP syntax.')

  pattern(%w( _mspxml ), lambda {
    :mspxml
  })
  descr(<<'EOT'
Export of the scheduled project in Microsoft Project XML format. This will
export the data of the fully scheduled project. The exported data include the
tasks, resources and the assignments of resources to tasks. This is only a
small subset of the data that TaskJuggler can manage. This export is intended
to share resource assignment data with other teams using Microsoft Project.
TaskJuggler manages assignments with a larger accuracy than the Microsoft
Project XML format can represent. This will inevitably lead to some rounding
errors and different interpretation of the data. The numbers you will see in
Microsoft Project are not necessarily an exact match of the numbers you see in
TaskJuggler. The XML file format requires the sequence of the tasks in the
file to follow the work breakdown structure. Hence all user provided sorting
directions will be ignored for this format.
EOT
       )
end

#rule_exportFormatsObject



1205
1206
1207
1208
1209
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1205

def rule_exportFormats
  pattern(%w( !exportFormat !moreExportFormats ), lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_exportHeaderObject



1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1211

def rule_exportHeader
  pattern(%w( _export !optionalID $STRING ), lambda {
    newReport(@val[1], @val[2], :export, @sourceFileInfo[0]) do
      unless @property.modified?('formats')
        @property.set('formats', [ :tjp ])
      end

      # By default, we export all scenarios.
      unless @property.modified?('scenarios')
        scenarios = Array.new(@project.scenarios.items) { |i| i }
        scenarios.delete_if { |sc| !@project.scenario(sc).get('active') }
        @property.set('scenarios', scenarios)
      end
      # Show all tasks, sorted by seqno-up.
      unless @property.modified?('hideTask')
        @property.set('hideTask',
                      LogicalExpression.new(LogicalOperation.new(0)))
      end
      unless @property.modified?('sortTasks')
        @property.set('sortTasks', [ [ 'seqno', true, -1 ] ])
      end
      # Show all resources, sorted by seqno-up.
      unless @property.modified?('hideResource')
        @property.set('hideResource',
                      LogicalExpression.new(LogicalOperation.new(0)))
      end
      unless @property.modified?('sortResources')
        @property.set('sortResources', [ [ 'seqno', true, -1 ] ])
      end
    end
  })
  arg(2, 'file name', <<'EOT'
The name of the report file to generate. It must end with a .tjp or .tji
extension, or use . to use the standard output channel.
EOT
     )
end

#rule_extendAttributesObject



1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1249

def rule_extendAttributes
  optional
  repeatable

  pattern(%w( _date !extendId  $STRING !extendOptionsBody ), lambda {
    # Extend the propertySet definition and parser rules
    if extendPropertySetDefinition(DateAttribute, nil)
      @ruleToExtendWithScenario.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '!date' ], lambda {
          @property[@val[0], @scenarioIdx] = @val[1]
        }))
    else
      @ruleToExtend.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '!date' ], lambda {
          @property.set(@val[0], @val[1])
        }))
    end
  })
  doc('date.extend', <<'EOT'
Extend the property with a new attribute of type date.
EOT
     )
  arg(2, 'name', 'The name of the new attribute. It is used as header ' +
                 'in report columns and the like.')

  pattern(%w( _number !extendId  $STRING !extendOptionsBody ), lambda {
    # Extend the propertySet definition and parser rules
    if extendPropertySetDefinition(FloatAttribute, nil)
      @ruleToExtendWithScenario.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '!number' ], lambda {
          @property[@val[0], @scenarioIdx] = @val[1]
        }))
    else
      @ruleToExtend.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '!number' ], lambda {
          @property.set(@val[0], @val[1])
        }))
    end
  })
  doc('number.extend', <<'EOT'
Extend the property with a new attribute of type number. Possible values for
this attribute could be integer or floating point numbers.
EOT
     )
  arg(2, 'name', 'The name of the new attribute. It is used as header ' +
                 'in report columns and the like.')

  pattern(%w( _reference !extendId $STRING !extendOptionsBody ), lambda {
    # Extend the propertySet definition and parser rules
    if extendPropertySetDefinition(ReferenceAttribute, nil)
      @ruleToExtendWithScenario.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '$STRING', '!referenceBody' ], lambda {
          @property[@val[0], @scenarioIdx] = [ @val[1], @val[2] ]
        }))
    else
      @ruleToExtend.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '$STRING', '!referenceBody' ], lambda {
          @property.set(@val[0], [ @val[1], @val[2] ])
        }))
    end
  })
  doc('reference.extend', <<'EOT'
Extend the property with a new attribute of type reference. A reference is a
URL and an optional text that will be shown instead of the URL if needed.
EOT
     )
  arg(2, 'name', 'The name of the new attribute. It is used as header ' +
                 'in report columns and the like.')

  pattern(%w( _richtext !extendId $STRING !extendOptionsBody ), lambda {
    # Extend the propertySet definition and parser rules
    if extendPropertySetDefinition(RichTextAttribute, nil)
      @ruleToExtendWithScenario.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '$STRING' ], lambda {
          @property[@val[0], @scenarioIdx] =
            newRichText(@val[1], @sourceFileInfo[1])
        }))
    else
      @ruleToExtend.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '$STRING' ], lambda {
          @property.set(@val[0], newRichText(@val[1], @sourceFileInfo[1]))
        }))
    end
  })
  doc('richtext.extend', <<'EOT'
Extend the property with a new attribute of type [[Rich_Text_Attributes|Rich
Text]].
EOT
     )
  arg(2, 'name', 'The name of the new attribute. It is used as header ' +
                 'in report columns and the like.')

  pattern(%w( _text !extendId $STRING !extendOptionsBody ), lambda {
    # Extend the propertySet definition and parser rules
    if extendPropertySetDefinition(StringAttribute, nil)
      @ruleToExtendWithScenario.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '$STRING' ], lambda {
          @property[@val[0], @scenarioIdx] = @val[1]
        }))
    else
      @ruleToExtend.addPattern(TextParser::Pattern.new(
        [ '_' + @val[1], '$STRING' ], lambda {
          @property.set(@val[0], @val[1])
        }))
    end
  })
  doc('text.extend', <<'EOT'
Extend the property with a new attribute of type text. A text is a character
sequence enclosed in single or double quotes.
EOT
     )
  arg(2, 'name', 'The name of the new attribute. It is used as header ' +
                 'in report columns and the like.')

end

#rule_extendBodyObject



1365
1366
1367
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1365

def rule_extendBody
  optionsRule('extendAttributes')
end

#rule_extendIdObject



1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1369

def rule_extendId
  pattern(%w( $ID ), lambda {
    unless (?A..?Z) === @val[0][0]
      error('extend_id_cap',
            "User defined attributes IDs must start with a capital letter",
            @sourceFileInfo[0])
    end
    @val[0]
  })
  arg(0, 'id', 'The ID of the new attribute. It can be used like the ' +
               'built-in IDs.')
end

#rule_extendOptionsObject



1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1382

def rule_extendOptions
  optional
  repeatable

  singlePattern('_inherit')
  doc('inherit.extend', <<'EOT'
If this attribute is used, the property extension will be inherited by
child properties from their parent property.
EOT
     )

  singlePattern('_scenariospecific')
  doc('scenariospecific.extend', <<'EOT'
If this attribute is used, the property extension is scenario specific. A
different value can be set for each scenario.
EOT
     )
end

#rule_extendOptionsBodyObject



1401
1402
1403
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1401

def rule_extendOptionsBody
  optionsRule('extendOptions')
end

#rule_extendPropertyObject



1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1405

def rule_extendProperty
  pattern(%w( !extendPropertyId ), lambda {
    case @val[0]
    when 'task'
      @ruleToExtend = @rules[:taskAttributes]
      @ruleToExtendWithScenario = @rules[:taskScenarioAttributes]
      @propertySet = @project.tasks
    when 'resource'
      @ruleToExtend = @rules[:resourceAttributes]
      @ruleToExtendWithScenario = @rules[:resourceScenarioAttributes]
      @propertySet = @project.resources
    end
  })
end

#rule_extendPropertyIdObject



1420
1421
1422
1423
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1420

def rule_extendPropertyId
  singlePattern('_task')
  singlePattern('_resource')
end

#rule_failObject



1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1425

def rule_fail
  pattern(%w( _fail !logicalExpression ), lambda {
    begin
      @property.set('fail', @property.get('fail') + [ @val[1] ])
    rescue AttributeOverwrite
    end
  })
  doc('fail', <<'EOT'
The fail attribute adds a [[logicalexpression|logical expression]] to the
property. The condition described by the logical expression is checked after
the scheduling and an error is raised if the condition evaluates to true. This
attribute is primarily intended for testing purposes.
EOT
     )
end

#rule_flagObject



1441
1442
1443
1444
1445
1446
1447
1448
1449
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1441

def rule_flag
  pattern(%w( $ID ), lambda {
    unless @project['flags'].include?(@val[0])
      error('undecl_flag', "Undeclared flag '#{@val[0]}'",
            @sourceFileInfo[0])
    end
    @val[0]
  })
end

#rule_flagListObject



1555
1556
1557
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1555

def rule_flagList
  listRule('moreFlagList', '!flag')
end

#rule_flagLogicalExpressionObject



1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1451

def rule_flagLogicalExpression
  pattern(%w( !flagOperation ), lambda {
    LogicalExpression.new(@val[0], sourceFileInfo)
  })
  doc('logicalflagexpression', <<'EOT'
A logical flag expression is a combination of operands and mathematical
operations.  The final result of a logical expression is always true or false.
Logical expressions are used the reduce the properties in a report to a
certain subset or to select alternatives for the cell content of a table. When
the logical expression is used with attributes like [[hidejournalentry]] and
evaluates to true for a certain property, this property is hidden or rolled-up
in the report.

Operands must be previously declared flags or another logical expression.
When you combine logical operations to a more complex expression, the
operators are evaluated from left to right. '''a | b & c''' is identical to
'''(a | b) & c'''. It's highly recommended that you always use brackets to
control the evaluation sequence. Currently, TaskJuggler does not support the
concept of operator precedence or right-left associativity. This may change in
the future.
EOT
     )
  also(%w( functions ))
end

#rule_flagOperandObject



1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1476

def rule_flagOperand
  pattern(%w( _( !flagOperation _) ), lambda {
    @val[1]
  })
  pattern(%w( _~ !flagOperand ), lambda {
    operation = LogicalOperation.new(@val[1])
    operation.operator = '~'
    operation
  })

  pattern(%w( $ID ), lambda {
    unless @project['flags'].include?(@val[0])
      error('operand_unkn_flag', "Undeclared flag '#{@val[0]}'",
            @sourceFileInfo[0])
    end
    LogicalFlag.new(@val[0])
  })
end

#rule_flagOperationObject



1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1495

def rule_flagOperation
  pattern(%w( !flagOperand !flagOperationChain ), lambda {
    operation = LogicalOperation.new(@val[0])
    if @val[1]
      # Further operators/operands create an operation tree.
      @val[1].each do |ops|
        operation = LogicalOperation.new(operation)
        operation.operator = ops[0]
        operation.operand2 = ops[1]
      end
    end
    operation
  })
  arg(0, 'operand', <<'EOT'
An operand is a declared flag. An operand can be a negated operand by
prefixing a ~ character or it can be another logical expression enclosed in
braces.
EOT
      )
end

#rule_flagOperationChainObject



1516
1517
1518
1519
1520
1521
1522
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1516

def rule_flagOperationChain
  optional
  repeatable
  pattern(%w( !flagOperatorAndOperand), lambda {
    @val[0]
  })
end

#rule_flagOperatorObject



1536
1537
1538
1539
1540
1541
1542
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1536

def rule_flagOperator
  singlePattern('_|')
  descr('The \'or\' operator')

  singlePattern('_&')
  descr('The \'and\' operator')
end

#rule_flagOperatorAndOperandObject



1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1524

def rule_flagOperatorAndOperand
  pattern(%w( !flagOperator !flagOperand), lambda{
    [ @val[0], @val[1] ]
  })
  arg(1, 'operand', <<'EOT'
An operand is a declared flag. An operand can be a negated operand by
prefixing a ~ character or it can be another logical expression enclosed in
braces.
EOT
      )
end

#rule_flagsObject



1545
1546
1547
1548
1549
1550
1551
1552
1553
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1545

def rule_flags
  pattern(%w( _flags !flagList ), lambda {
    @val[1].each do |flag|
      next if @property['flags', @scenarioIdx].include?(flag)

      @property['flags', @scenarioIdx] += [ flag ]
    end
  })
end

#rule_formatsObject



1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1559

def rule_formats
  pattern(%w( _formats !outputFormats ), lambda {
    @property.set('formats', @val[1])
  })
  doc('formats', <<'EOT'
This attribute defines for which output formats the report should be
generated. By default, this list is empty. Unless a formats attribute was
added to a report definition, no output will be generated for this report.

As reports are composable, a report may include other report definitions. A
format definition is only needed for the outermost report that includes the
others.
EOT
     )
end

#rule_functionPatternsObject



1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1620

def rule_functionPatterns
  # This rule is not used by the parser. It's only for the documentation.
  pattern(%w( _hasalert _( $INTEGER _, !date _) ))
  doc('hasalert', <<'EOT'
Will evaluate to true if the current property has a current alert message within the report time frame and with at least the provided alert level.
EOT
     )
  arg(2, 'Level', 'The minimum required alert level to be considered.')

  pattern(%w( _isactive _( $ID _) ))
  doc('isactive', <<'EOT'
Will evaluate to true for tasks and resources if they have bookings in
the scenario during the report time frame.
EOT
     )
  arg(2, 'ID', 'A scenario ID')

  pattern(%w( _ischildof _( $ID _) ))
  doc('ischildof', <<'EOT'
Will evaluate to true for tasks and resources if current property is a child
of the provided parent property.
EOT
     )
  arg(2, 'ID', 'The ID of the parent')

  pattern(%w( _isdependencyof _( $ID _, $ID _, $INTEGER _) ))
  doc('isdependencyof', <<'EOT'
Will evaluate to true for tasks that depend on the specified task in
the specified scenario and are no more than distance tasks away. If
distance is 0, all dependencies are considered independent of their
distance.
EOT
     )
  arg(2, 'Task ID', 'The ID of a defined task')
  arg(4, 'Scenario ID', 'A scenario ID')
  arg(6, 'Distance', 'The maximum task distance to be considered')

  pattern(%w( _isdutyof _( $ID _, $ID _) ))
  doc('isdutyof', <<'EOT'
Will evaluate to true for tasks that have the specified resource
assigned to it in the specified scenario.
EOT
     )
  arg(2, 'Resource ID', 'The ID of a defined resource')
  arg(4, 'Scenario ID', 'A scenario ID')

  pattern(%w( _isfeatureof _( $ID _, $ID _) ))
  doc('isfeatureof', <<'EOT'
If the provided task or any of its sub-tasks depend on this task or any of its
sub-tasks, we call this task a feature of the provided task.
EOT
     )
  arg(2, 'Task ID', 'The ID of a defined task')
  arg(4, 'Scenario ID', 'A scenario ID')

  pattern(['_isleaf', '_(', '_)' ])
  doc('isleaf', 'The result is true if the property is not a container.')

  pattern(%w( _ismilestone _( $ID _) ))
  doc('ismilestone', <<'EOT'
The result is true if the property is a milestone in the provided scenario.
EOT
     )
  arg(2, 'Scenario ID', 'A scenario ID')

  pattern(%w( _isongoing _( $ID _) ))
  doc('isongoing', <<'EOT'
Will evaluate to true for tasks that overlap with the report period in the given
scenario.
EOT
     )
  arg(2, 'ID', 'A scenario ID')

  pattern(['_isresource', '_(', '_)' ])
  doc('isresource', 'The result is true if the property is a resource.')

  pattern(%w( _isresponsibilityof _( $ID _, $ID _) ))
  doc('isresponsibilityof', <<'EOT'
Will evaluate to true for tasks that have the specified resource
assigned as [[responsible]] in the specified scenario.
EOT
     )
  arg(2, 'Resource ID', 'The ID of a defined resource')
  arg(4, 'Scenario ID', 'A scenario ID')

  pattern(['_istask', '_(', '_)' ])
  doc('istask', 'The result is true if the property is a task.')

  pattern(%w( _isvalid _( $ID _) ))
  doc('isvalid', 'Returns false if argument is not an assigned or ' +
                 'properly computed value.')

  pattern(%w( _treelevel _( _) ))
  doc('treelevel', <<'EOT'
Returns the nesting level of a property in the property tree.
Top level properties have a level of 1, their children 2 and so on.
EOT
     )
end

#rule_functionsObject



1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1575

def rule_functions
  # This rule is not used by the parser. It's only for the documentation.
  pattern(%w( !functionsBody ))
  doc('functions', <<'EOT'
The following functions are supported in logical expressions. These functions
are evaluated in logical conditions such as hidetask or rollupresource. For
the evaluation, implicit and explicit parameters are used.

All functions may operate on the current property and the scope property. The
scope property is the enclosing property in reports with nested properties.
Imagine e. g. a task report with nested resources. When the function is called
for a task line, the task is the property and we don't have a scope property.
When the function is called for a resource line, the resource is the property
and the enclosing task is the scope property.

The number of arguments that are passed in brackets to the function depends
on the specific function. See the reference for details on each function.

All functions can be suffixed with an underscore character. In that case, the
function is operating on the scope property as if it were the property. The
original property is ignored in that case. In our task report example from
above, calling a function with an appended underscore would mean that a task
line would be evaluated for the enclosing resource.

In the example below you can see how this can be used. To generate a task
report that lists all assigned leaf resources for leaf task lines only we use
the expression

 hideresource ~(isleaf() & isleaf_())

The tilde in front of the bracketed expression means not that expression. In
other words: show resources that are leaf resources and show them for leaf
tasks only. The regular form isleaf() (without the appended underscore)
operates on the resource. The isleaf_() variant operates on the
enclosing task.
EOT
     )
  example('LogicalFunction', '1')
end

#rule_functionsBodyObject



1615
1616
1617
1618
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1615

def rule_functionsBody
  # This rule is not used by the parser. It's only for the documentation.
  optionsRule('functionPatterns')
end

#rule_hAlignmentObject



1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1720

def rule_hAlignment
  pattern(%w( _center ), lambda {
    :center
  })
  doc('halign.center', 'Center the cell content')

  pattern(%w( _left ), lambda {
    :left
  })
  doc('halign.left', 'Left align the cell content')

  pattern(%w( _right ), lambda {
    :right
  })
  doc('halign.right', 'Right align the cell content')
end

#rule_headlineObject



1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1737

def rule_headline
  pattern(%w( _headline $STRING ), lambda {
    @property.set('headline', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('headline', <<'EOT'
Specifies the headline for a report.
EOT
     )
  arg(1, 'text', <<'EOT'
The text used for the headline. It is interpreted as
[[Rich_Text_Attributes|Rich Text]].
EOT
     )
end

#rule_hideaccountObject



1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1752

def rule_hideaccount
  pattern(%w( _hideaccount !logicalExpression ), lambda {
    @property.set('hideAccount', @val[1])
  })
  doc('hideaccount', <<'EOT'
Do not include accounts that match the specified [[logicalexpression|logical
expression]]. If the report is sorted in ''''tree'''' mode (default) then
enclosing accounts are
listed even if the expression matches the account.
EOT
     )
  also(%w( sortaccounts ))
end

#rule_hidejournalentryObject



1766
1767
1768
1769
1770
1771
1772
1773
1774
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1766

def rule_hidejournalentry
  pattern(%w( _hidejournalentry !flagLogicalExpression ), lambda {
    @property.set('hideJournalEntry', @val[1])
  })
  doc('hidejournalentry', <<'EOT'
Do not include journal entries that match the specified logical expression.
EOT
     )
end

#rule_hideresourceObject



1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1776

def rule_hideresource
  pattern(%w( _hideresource !logicalExpression ), lambda {
    @property.set('hideResource', @val[1])
  })
  doc('hideresource', <<'EOT'
Do not include resources that match the specified [[logicalexpression|logical
expression]]. If the report is sorted in ''''tree'''' mode (default) then
enclosing resources are listed even if the expression matches the resource.
EOT
     )
  also(%w( sortresources ))
end

#rule_hidetaskObject



1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1789

def rule_hidetask
  pattern(%w( _hidetask !logicalExpression ), lambda {
    @property.set('hideTask', @val[1])
  })
  doc('hidetask', <<'EOT'
Do not include tasks that match the specified [[logicalexpression|logical
expression]]. If the report is sorted in ''''tree'''' mode (default) then
enclosing tasks are listed even if the expression matches the task.
EOT
     )
  also(%w( sorttasks ))
end

#rule_iCalReportObject



1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1801

def rule_iCalReport
  pattern(%w( !iCalReportHeader !iCalReportBody ), lambda {
    @property = nil
  })
  doc('icalreport', <<'EOT'
Generates an RFC5545 compliant iCalendar file. This file can be used to export
task information to calendar applications or other tools that read iCalendar
files.
EOT
     )
end

#rule_iCalReportAttributesObject



1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1816

def rule_iCalReportAttributes
  optional
  repeatable

  pattern(%w( !hideresource ))
  pattern(%w( !hidejournalentry ))
  pattern(%w( !hidetask ))
  pattern(%w( !reportEnd ))
  pattern(%w( !reportPeriod ))
  pattern(%w( !reportStart ))
  pattern(%w( !rollupresource ))
  pattern(%w( !rolluptask ))
  pattern(%w( _novevents), lambda { @property.set('novevents', [ true ]) })
  doc('novevents', <<'EOT'
Don't add VEVENT entries to generated [[icalreport]]s.
EOT
  )

  pattern(%w( _scenario !scenarioId ), lambda {
    # Don't include disabled scenarios in the report
    sc = @val[1]
    unless @project.scenario(sc).get('active')
      warning('ical_sc_disabled',
              "Scenario #{sc} has been disabled")
    else
      @property.set('scenarios', [ @val[1] ])
    end
  })
  doc('scenario.ical', <<'EOT'
ID of the scenario that should be included in the report. By default, the
top-level scenario will be included. This attribute can be used to select another
scenario.
EOT
     )
end

#rule_iCalReportBodyObject



1812
1813
1814
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1812

def rule_iCalReportBody
  optionsRule('iCalReportAttributes')
end

#rule_iCalReportHeaderObject



1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1852

def rule_iCalReportHeader
  pattern(%w( _icalreport !optionalID $STRING ), lambda {
    newReport(@val[1], @val[2], :iCal, @sourceFileInfo[0]) do
      @property.set('formats', [ :iCal ])

      # By default, we export only the first scenario.
      unless @project.scenario(0).get('active')
        @property.set('scenarios', [ 0 ])
      end
      # Show all tasks, sorted by seqno-up.
      @property.set('hideTask', LogicalExpression.new(LogicalOperation.new(0)))
      @property.set('sortTasks', [ [ 'seqno', true, -1 ] ])
      # Show all resources, sorted by seqno-up.
      @property.set('hideResource',
                    LogicalExpression.new(LogicalOperation.new(0)))
      @property.set('sortResources', [ [ 'seqno', true, -1 ] ])
      # Show all journal entries.
      @property.set('hideJournalEntry',
                    LogicalExpression.new(LogicalOperation.new(0)))
      # Add VEVENT entries to icalreports by default
      @property.set('novevents', [ false ])
    end
  })
  arg(1, 'file name', <<'EOT'
The name of the report file to generate without an extension.  Use . to use
the standard output channel.
EOT
     )
end

#rule_idOrAbsoluteIdObject



1882
1883
1884
1885
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1882

def rule_idOrAbsoluteId
  singlePattern('$ID')
  singlePattern('$ABSOLUTE_ID')
end

#rule_includeAttributesObject



1887
1888
1889
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1887

def rule_includeAttributes
  optionsRule('includeAttributesBody')
end

#rule_includeAttributesBodyObject



1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1891

def rule_includeAttributesBody
  optional
  repeatable

  pattern(%w( _accountprefix !accountId ), lambda {
    @accountprefix = @val[1].fullId
  })
  doc('accountprefix', <<'EOT'
This attribute can be used to insert the accounts of the included file as
sub-account of the account specified by ID. The parent account must already be
defined.
EOT
  )
  arg(1, 'account ID', 'The absolute ID of an already defined account')

  pattern(%w( _reportprefix !reportId ), lambda {
    @reportprefix = @val[1].fullId
  })
  doc('reportprefix', <<'EOT'
This attribute can be used to insert the reports of the included file as
sub-report of the report specified by ID. The parent report must already
be defined.
EOT
  )
  arg(1, 'report ID', 'The absolute ID of an already defined report.')

  pattern(%w( _resourceprefix !resourceId ), lambda {
    @resourceprefix = @val[1].fullId
  })
  doc('resourceprefix', <<'EOT'
This attribute can be used to insert the resources of the included file as
sub-resource of the resource specified by ID. The parent resource must already
be defined.
EOT
  )
  arg(1, 'resource ID', 'The ID of an already defined resource')

  pattern(%w( _taskprefix !taskId ), lambda {
    @taskprefix = @val[1].fullId
  })
  doc('taskprefix', <<'EOT'
This attribute can be used to insert the tasks of the included file as
sub-task of the task specified by ID. The parent task must already be defined.
EOT
  )
  arg(1, 'task ID', 'The absolute ID of an already defined task.')
end

#rule_includeFileObject



1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1939

def rule_includeFile
  pattern(%w( !includeFileName ), lambda {
    unless @project
      error('include_before_project',
            "You must declare the project header before you include other " +
            "files.")
    end
    @project.inputFiles << @scanner.include(@val[0], @sourceFileInfo[0]) do
      popFileStack
    end
  })
end

#rule_includeFileNameObject



1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1952

def rule_includeFileName
  pattern(%w( $STRING ), lambda {
    unless @val[0][-4, 4] == '.tji'
      error('bad_include_suffix', "Included files must have a '.tji'" +
                                  "extension: '#{@val[0]}'",
            @sourceFileInfo[0])
    end
    pushFileStack
    @val[0]
  })
  arg(0, 'filename', <<'EOT'
Name of the file to include. This must have a ''''.tji'''' extension. The name
may have an absolute or relative path. You need to use ''''/'''' characters to
separate directories.
EOT
     )
end

#rule_includePropertiesObject



1970
1971
1972
1973
1974
1975
1976
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1970

def rule_includeProperties
  pattern(%w( !includeFileName !includeAttributes ), lambda {
    @project.inputFiles << @scanner.include(@val[0], @sourceFileInfo[0]) do
      popFileStack
    end
  })
end

#rule_intervalObject



2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2010

def rule_interval
  pattern(%w( !date !intervalEnd ), lambda {
    mode = @val[1][0]
    endSpec = @val[1][1]
    if mode == 0
      unless @val[0] < endSpec
        error('start_before_end', "The end date (#{endSpec}) must be after " +
              "the start date (#{@val[0]}).", @sourceFileInfo[0])
      end
      TimeInterval.new(@val[0], endSpec)
    else
      TimeInterval.new(@val[0], @val[0] + endSpec)
    end
  })
  doc('interval2', <<'EOT'
There are two ways to specify a date interval. The first is the most
obvious. A date interval consists of a start and end DATE. Watch out for end
dates without a time specification! Date specifications are 0 extended. An
end date without a time is expanded to midnight that day. So the day of the
end date is not included in the interval! The start and end dates must be separated by a hyphen character.

The second form specifies the start date and an interval duration. The
duration must be prefixed by a plus character.
EOT
     )
end

#rule_intervalDurationObject



2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2037

def rule_intervalDuration
  pattern(%w( !number !durationUnit ), lambda {
    convFactors = [ 60, # minutes
                    60 * 60, # hours
                    60 * 60 * 24, # days
                    60 * 60 * 24 * 7, # weeks
                    60 * 60 * 24 * 30.4167, # months
                    60 * 60 * 24 * 365 # years
                   ]
    if @val[0] == 0.0
      error('zero_duration', "The interval duration may not be 0.",
            @sourceFileInfo[1])
    end
    duration = (@val[0] * convFactors[@val[1]]).to_i
    resolution = @project.nil? ? 60 * 60 : @project['scheduleGranularity']
    if @val[1] == 4
      # If the duration unit is months, we have to align the duration with
      # the timing resolution of the project.
      duration = (duration / resolution).to_i * resolution
    end
    # Make sure the interval aligns with the timing resolution.
    if duration % resolution != 0
      error('iv_duration_not_aligned',
            "The interval duration must be a multiple of the specified " +
            "timing resolution (#{resolution / 60} min) of the project.")
    end
    duration
  })
  arg(0, 'duration', 'The duration of the interval. May not be 0 and must ' +
                     'be a multiple of [[timingresolution]].')
end

#rule_intervalEndObject



2069
2070
2071
2072
2073
2074
2075
2076
2077
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2069

def rule_intervalEnd
  pattern([ '_-', '!date' ], lambda {
    [ 0, @val[1] ]
  })

  pattern(%w( _+ !intervalDuration ), lambda {
    [ 1, @val[1] ]
  })
end

#rule_intervalOptionalObject



2094
2095
2096
2097
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2094

def rule_intervalOptional
  optional
  singlePattern('!interval')
end

#rule_intervalOptionalEndObject



2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2079

def rule_intervalOptionalEnd
  optional
  pattern([ '_-', '!date' ], lambda {
    [ 0, @val[1] ]
  })

  pattern(%w( _+ !intervalDuration ), lambda {
    [ 1, @val[1] ]
  })
end

#rule_intervalOrDateObject



1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 1978

def rule_intervalOrDate
  pattern(%w( !date !intervalOptionalEnd ), lambda {
    if @val[1]
      mode = @val[1][0]
      endSpec = @val[1][1]
      if mode == 0
        unless @val[0] < endSpec
          error('start_before_end', "The end date (#{endSpec}) must be " +
                "after the start date (#{@val[0]}).", @sourceFileInfo[0])
        end
        TimeInterval.new(@val[0], endSpec)
      else
        TimeInterval.new(@val[0], @val[0] + endSpec)
      end
    else
      TimeInterval.new(@val[0], @val[0].sameTimeNextDay)
    end
  })
  doc('interval3', <<'EOT'
There are three ways to specify a date interval. The first is the most
obvious. A date interval consists of a start and end DATE. Watch out for end
dates without a time specification! Date specifications are 0 extended. An
end date without a time is expanded to midnight that day. So the day of the
end date is not included in the interval! The start and end dates must be separated by a hyphen character.

In the second form, the end date is omitted. A 24 hour interval is assumed.

The third form specifies the start date and an interval duration. The duration must be prefixed by a plus character.
EOT
     )
end

#rule_intervalsObject



2090
2091
2092
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2090

def rule_intervals
  listRule('moreIntervals', '!intervalOrDate')
end

#rule_intervalsOptionalObject



2099
2100
2101
2102
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2099

def rule_intervalsOptional
  optional
  singlePattern('!intervals')
end

#rule_journalEntryObject



2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2190

def rule_journalEntry
  pattern(%w( !journalEntryHeader !journalEntryBody ), lambda {
    @val[0]
  })
  doc('journalentry', <<'EOT'
This attribute adds an entry to the journal of the project. A journal can be
used to record events, decisions or news that happened at a particular moment
during the project. Depending on the context, a journal entry may or may not
be associated with a specific property or author.

A journal entry can consist of up to three parts. The headline is mandatory
and should be only 5 to 10 words long. The introduction is optional and should
be only one or two sentences long. All other details should be put into the
third part.

Depending on the context, journal entries are listed with headlines only, as
headlines plus introduction or in full.
EOT
     )
end

#rule_journalEntryAttributesObject



2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2211

def rule_journalEntryAttributes
  optional
  repeatable

  pattern(%w( _alert !alertLevel ), lambda {
    @journalEntry.alertLevel = @val[1]
  })
  doc('alert', <<'EOT'
Specify the alert level for this entry. This attribute is intended to be used for
status reporting. When used for a journal entry that is associated with a
property, the value can be reported in the alert column. When multiple entries
have been specified for the property, the entry with the date closest to the
report end date will be used. Container properties will inherit the highest
alert level of all its sub properties unless it has an own journal entry dated
closer to the report end than all of its sub properties.
EOT
     )

  pattern(%w( !author ))

  pattern(%w( _flags !flagList ), lambda {
    @val[1].each do |flag|
      next if @journalEntry.flags.include?(flag)

      @journalEntry.flags << flag
    end
  })
  doc('flags.journalentry', <<'EOT'
Journal entries can have flags attached to them. These can be used to
include only entries in a report that have a certain flag.
EOT
     )

  pattern(%w( !summary ))

  pattern(%w( !details ))
end

#rule_journalEntryBodyObject



2249
2250
2251
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2249

def rule_journalEntryBody
  optionsRule('journalEntryAttributes')
end

#rule_journalEntryHeaderObject



2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2253

def rule_journalEntryHeader
  pattern(%w( _journalentry !valDate $STRING ), lambda {
    @journalEntry = JournalEntry.new(@project['journal'], @val[1], @val[2],
                                     @property, @sourceFileInfo[0])
  })
  arg(2, 'headline', <<'EOT'
The headline of the journal entry. It will be interpreted as
[[Rich_Text_Attributes|Rich Text]].
EOT
     )
end

#rule_journalReportAttributesObject



2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2104

def rule_journalReportAttributes
  pattern(%w( _journalattributes !journalReportAttributesList ), lambda {
    @property.set('journalAttributes', @val[1])
  })
  doc('journalattributes', <<'EOT'
A list that determines which of the journal attributes should be included in
the journal report.
EOT
     )
  allOrNothingListRule('journalReportAttributesList',
                       { 'alert' => 'Include the alert status',
                         'author' => 'Include the author if known',
                         'date' => 'Include the date',
                         'details' => 'Include the details',
                         'flags' => 'Include the flags',
                         'headline' => 'Include the headline',
                         'property' => 'Include the task or resource name',
                         'propertyid' => 'Include the property ID. ' +
                                         'Requires \'property\'.',
                         'summary' => 'Include the summary',
                         'timesheet' => 'Include the timesheet information.' +
                                        ' Requires \'property\'.'})
end

#rule_journalReportModeObject



2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2128

def rule_journalReportMode
  pattern(%w( _journal ), lambda { :journal })
  descr(<<'EOT'
This is the regular journal. It contains all journal entries that are dated in
the query interval. If a property is given, only entries of this property are
included. Without a property context, all the project entries are included
unless hidden by other attributes like [[hidejournalentry]].
EOT
     )
  pattern(%w( _journal_sub ), lambda { :journal_sub })
  descr(<<'EOT'
This mode only yields entries if used in the context of a task. It contains
all journal entries that are dated in the query interval for the task and all
its sub tasks.
EOT
     )
  pattern(%w( _status_dep ), lambda { :status_dep })
  descr(<<'EOT'
In this mode only the last entries before the report end date for each
property and all its sub-properties and their dependencies are included. If
there are multiple entries at the exact same date, then all these entries are
included.
EOT
     )
  pattern(%w( _status_down ), lambda { :status_down })
  descr(<<'EOT'
In this mode only the last entries before the report end date for each
property and all its sub-properties are included. If there are multiple entries
at the exact same date, then all these entries are included.
EOT
     )
  pattern(%w( _status_up ), lambda { :status_up })
  descr(<<'EOT'
In this mode only the last entries before the report end date for each
property are included. If there are multiple entries at the exact same date,
then all these entries are included. If any of the parent properties has a
more recent entry that is still before the report end date, no entries will be
included.
EOT
     )
  pattern(%w( _alerts_dep ), lambda { :alerts_dep })
  descr(<<'EOT'
In this mode only the last entries before the report end date for the context
property and all its sub-properties and their dependencies are included. If
there are multiple entries at the exact same date, then all these entries are
included. In contrast to the ''''status_down'''' mode, only entries with an
alert level above the default level, and only those with the highest overall
alert level are included.
EOT
     )
  pattern(%w( _alerts_down ), lambda { :alerts_down })
  descr(<<'EOT'
In this mode only the last entries before the report end date for the context
property and all its sub-properties is included. If there are multiple entries
at the exact same date, then all these entries are included. In contrast to
the ''''status_down'''' mode, only entries with an alert level above the
default level, and only those with the highest overall alert level are
included.
EOT
     )
end

#rule_journalSortCriteriaObject



2265
2266
2267
2268
2269
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2265

def rule_journalSortCriteria
  pattern(%w( !journalSortCriterium !moreJournalSortCriteria ), lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_journalSortCriteriumObject



2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2271

def rule_journalSortCriterium
  pattern(%w( $ABSOLUTE_ID ), lambda {
    supported = []
    JournalEntryList::SortingAttributes.each do |attr|
      supported << "#{attr}.up"
      supported << "#{attr}.down"
    end
    unless supported.include?(@val[0])
      error('bad_journal_sort_criterium',
            "Unsupported sorting criterium #{@val[0]}. Must be one of " +
            "#{supported.join(', ')}.")
    end
    attr, direction = @val[0].split('.')
    [ attr.intern, direction == 'up' ? 1 : -1 ]
  })
end

#rule_leafResourceIdObject



2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2288

def rule_leafResourceId
  pattern(%w( !resourceId ), lambda {
    resource = @val[0]
    unless resource.leaf?
      error('leaf_resource_id_expected',
            "#{resource.id} is not a leaf resource.", @sourceFileInfo[0])
    end
    resource
  })
  arg(0, 'resource', 'The ID of a leaf resource')
end

#rule_leaveObject



2300
2301
2302
2303
2304
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2300

def rule_leave
  pattern(%w( !leaveType !vacationName !intervalOrDate ), lambda {
    Leave.new(@val[0].intern, @val[2], @val[1])
  })
end

#rule_leaveAllowanceObject



2318
2319
2320
2321
2322
2323
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2318

def rule_leaveAllowance
  pattern(%w( _annual !valDate !optionalMinus
              !nonZeroWorkingDuration ), lambda {
    LeaveAllowance.new(:annual, @val[1], (@val[2] ? -1 : 1) * @val[3])
  })
end

#rule_leaveAllowanceListObject



2325
2326
2327
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2325

def rule_leaveAllowanceList
  listRule('moreLeaveAllowanceList', '!leaveAllowance')
end

#rule_leaveAllowancesObject



2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2329

def rule_leaveAllowances
  pattern(%w( _leaveallowances !leaveAllowanceList ), lambda {
    appendScListAttribute('leaveallowances', @val[1])
  })
  doc('leaveallowance', <<'EOT'
Add or subtract leave allowances. Currently, only allowances for the annual
leaves are supported. Allowances can be negative to deal with expired
allowances. The ''''leaveallowancebalance'''' report [[columns|column]] can be
used to report the current annual leave balance.

Leaves outside of the project period are silently ignored and will not be
considered in the leave balance calculation. Therefore, leave allowances are
only allowed within the project period.
EOT
    )
  level(:beta)
  example('Leave')
end

#rule_leaveListObject



2306
2307
2308
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2306

def rule_leaveList
  listRule('moreLeaveList', '!leave')
end

#rule_leaveNameObject



2310
2311
2312
2313
2314
2315
2316
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2310

def rule_leaveName
  optional
  pattern(%w( $STRING ), lambda {
    @val[0]
  })
  arg(0, 'name', 'An optional name or reason for the leave')
end

#rule_leavesObject



2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2348

def rule_leaves
  pattern(%w( _leaves !leaveList ), lambda {
    LeaveList.new(@val[1])
  })
  doc('leaves', <<'EOT'
Describe a list of leave periods. A leave can be due to a public holiday,
personal or sick leave. At global scope, the leaves determine which day is
considered a working day. Subsequent resource definitions will inherit the
leave list.

Leaves can be defined at global level, at resource level and at shift level
and intervals may overlap. The leave types have different priorities. A higher
priority leave type can overwrite a lower priority type. This means that
resource level leaves can overwrite global leaves when they have a higher
priority. A sub resource can overwrite a leave of an enclosing resource.

Leave periods outside of the project interval are silently ignored. For leave
periods that are partially outside of the project period only the part inside
the project period will be considered.
EOT
     )
  example('Leave')
end

#rule_leaveTypeObject



2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2372

def rule_leaveType
  singlePattern('_project')
  descr('Assignment to another project (lowest priority)')

  singlePattern('_annual')
  descr('Personal leave based on annual allowance')

  singlePattern('_special')
  descr('Personal leave based on a special occasion')

  singlePattern('_sick')
  descr('Sick leave')

  singlePattern('_unpaid')
  descr('Unpaid leave')

  singlePattern('_holiday')
  descr('Public or bank holiday')

  singlePattern('_unemployed')
  descr('Not employeed (highest priority)')
end

#rule_limitAttributesObject



2395
2396
2397
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2395

def rule_limitAttributes
  optionsRule('limitAttributesBody')
end

#rule_limitAttributesBodyObject



2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2399

def rule_limitAttributesBody
  optional
  repeatable

  pattern(%w( _end !valDate ), lambda {
    @limitInterval.end = @val[1]
  })
  doc('end.limit', <<'EOT'
The end date of the limit interval. It must be within the project time frame.
EOT
  )

  pattern(%w( _period !valInterval ), lambda {
    @limitInterval = ScoreboardInterval.new(@project['start'],
                                            @project['scheduleGranularity'],
                                            @val[1].start, @val[1].end)
  })
  doc('period.limit', <<'EOT'
This property is a shortcut for setting the start and end dates of the limit
interval. Both dates must be within the project time frame.
EOT
     )

  pattern(%w( _resources !resourceLeafList ), lambda {
    @limitResources = @val[1]
  })
  doc('resources.limit', <<'EOT'
When [[limits]] are used in a [[task]] context, the limits can be restricted
to a list of resources that are allocated to the task. In that case each
listed resource will not be allocated more than the specified upper limit.
Lower limits have no impact on the scheduler but do generate a warning when
not met.  All specified resources must be leaf resources.
EOT
     )
  example('Limits-1', '5')

  pattern(%w( _start !valDate ), lambda {
    @limitInterval.start = @val[1]
  })
  doc('start.limit', <<'EOT'
The start date of the limit interval. It must be within the project time frame.
EOT
  )
end

#rule_limitsObject



2454
2455
2456
2457
2458
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2454

def rule_limits
  pattern(%w( !limitsHeader !limitsBody ), lambda {
    @val[0]
  })
end

#rule_limitsAttributesObject



2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2460

def rule_limitsAttributes
  optional
  repeatable

  pattern(%w( _dailymax !limitValue !limitAttributes), lambda {
    setLimit(@val[0], @val[1], @limitInterval)
  })
  doc('dailymax', <<'EOT'
Set a maximum limit for each calendar day.
EOT
     )
  example('Limits-1', '1')

  pattern(%w( _dailymin !limitValue !limitAttributes), lambda {
    setLimit(@val[0], @val[1], @limitInterval)
  })
  doc('dailymin', <<'EOT'
Minimum required effort for any calendar day. This value cannot be guaranteed by
the scheduler. It is only checked after the schedule is complete. In case the
minimum required amount has not been reached, a warning will be generated.
EOT
     )
  example('Limits-1', '4')

  pattern(%w( _maximum !limitValue !limitAttributes), lambda {
    setLimit(@val[0], @val[1], @limitInterval)
  })
  doc('maximum', <<'EOT'
Set a maximum limit for the specified period. You must ensure that the overall
effort can be achieved!
EOT
     )

  pattern(%w( _minimum !limitValue !limitAttributes), lambda {
    setLimit(@val[0], @val[1], @limitInterval)
  })
  doc('minimum', <<'EOT'
Set a minim limit for each calendar month. This will only result in a warning
if not met.
EOT
     )

  pattern(%w( _monthlymax !limitValue !limitAttributes), lambda {
    setLimit(@val[0], @val[1], @limitInterval)
  })
  doc('monthlymax', <<'EOT'
Set a maximum limit for each calendar month.
EOT
     )

  pattern(%w( _monthlymin !limitValue !limitAttributes), lambda {
    setLimit(@val[0], @val[1], @limitInterval)
  })
  doc('monthlymin', <<'EOT'
Minimum required effort for any calendar month. This value cannot be
guaranteed by the scheduler. It is only checked after the schedule is
complete. In case the minimum required amount has not been reached, a warning
will be generated.
EOT
     )

  pattern(%w( _weeklymax !limitValue !limitAttributes), lambda {
    setLimit(@val[0], @val[1], @limitInterval)
  })
  doc('weeklymax', <<'EOT'
Set a maximum limit for each calendar week.
EOT
     )

  pattern(%w( _weeklymin !limitValue !limitAttributes), lambda {
    setLimit(@val[0], @val[1], @limitInterval)
  })
  doc('weeklymin', <<'EOT'
Minimum required effort for any calendar week. This value cannot be guaranteed by
the scheduler. It is only checked after the schedule is complete. In case the
minimum required amount has not been reached, a warning will be generated.
EOT
     )
end

#rule_limitsBodyObject



2540
2541
2542
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2540

def rule_limitsBody
  optionsRule('limitsAttributes')
end

#rule_limitsHeaderObject



2544
2545
2546
2547
2548
2549
2550
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2544

def rule_limitsHeader
  pattern(%w( _limits ), lambda {
    @limits = Limits.new
    @limits.setProject(@project)
    @limits
  })
end

#rule_limitValueObject



2444
2445
2446
2447
2448
2449
2450
2451
2452
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2444

def rule_limitValue
  pattern([ '!nonZeroWorkingDuration' ], lambda {
    @limitInterval = ScoreboardInterval.new(@project['start'],
                                            @project['scheduleGranularity'],
                                            @project['start'], @project['end'])
    @limitResources = []
    @val[0]
  })
end

#rule_listOfDaysObject



2552
2553
2554
2555
2556
2557
2558
2559
2560
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2552

def rule_listOfDays
  pattern(%w( !weekDayInterval !moreListOfDays), lambda {
    weekDays = Array.new(7, false)
    ([ @val[0] ] + (@val[1] ? @val[1] : [])).each do |dayList|
      7.times { |i| weekDays[i] = true if dayList[i] }
    end
    weekDays
  })
end

#rule_listOfTimesObject



2562
2563
2564
2565
2566
2567
2568
2569
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2562

def rule_listOfTimes
  pattern(%w( _off ), lambda {
    [ ]
  })
  pattern(%w( !timeInterval !moreTimeIntervals ), lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_listTypeObject



2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2571

def rule_listType
  pattern([ '_bullets' ], lambda { :bullets })
  descr('List items as bullet list')

  pattern([ '_comma' ], lambda { :comma })
  descr('List items as comma separated list')

  pattern([ '_numbered' ], lambda { :numbered })
  descr('List items as numbered list')
end

#rule_loadunitObject



2582
2583
2584
2585
2586
2587
2588
2589
2590
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2582

def rule_loadunit
  pattern(%w( _loadunit !loadunitName ), lambda {
    @property.set('loadUnit', @val[1])
  })
  doc('loadunit', <<'EOT'
Determines what unit should be used to display all load values in this report.
EOT
     )
end

#rule_loadunitNameObject



2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2592

def rule_loadunitName
  pattern([ '_days' ], lambda { :days })
  descr('Display all load and duration values as days.')

  pattern([ '_hours' ], lambda { :hours })
  descr('Display all load and duration values as hours.')

  pattern([ '_longauto'] , lambda { :longauto })
  descr(<<'EOT'
Automatically select the unit that produces the shortest and most readable
value. The unit name will not be abbreviated. It will not use quarters since
it is not common.
EOT
       )

  pattern([ '_minutes' ], lambda { :minutes })
  descr('Display all load and duration values as minutes.')

  pattern([ '_months' ], lambda { :months })
  descr('Display all load and duration values as months.')

  pattern([ '_quarters' ], lambda { :quarters })
  descr('Display all load and duration values as quarters.')

  pattern([ '_shortauto' ], lambda { :shortauto })
  descr(<<'EOT'
Automatically select the unit that produces the shortest and most readable
value. The unit name will be abbreviated. It will not use quarters since it is
not common.
EOT
       )

  pattern([ '_weeks' ], lambda { :weeks })
  descr('Display all load and duration values as weeks.')

  pattern([ '_years' ], lambda { :years })
  descr('Display all load and duration values as years.')
end

#rule_logicalExpressionObject



2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2631

def rule_logicalExpression
  pattern(%w( !operation ), lambda {
    LogicalExpression.new(@val[0], sourceFileInfo)
  })
  pattern(%w( _@ !allOrNone ), lambda {
    LogicalExpression.new(LogicalOperation.new(@val[1]), sourceFileInfo)
  })
  doc('logicalexpression', <<'EOT'
A logical expression is a combination of operands and mathematical operations.
The final result of a logical expression is always true or false. Logical
expressions are used the reduce the properties in a report to a certain subset
or to select alternatives for the cell content of a table. When the
logical expression is used with attributes like [[hidetask]] or [[hideresource]] and
evaluates to true for a certain property, this property is hidden or rolled-up
in the report.

Operands can be previously declared flags, built-in [[functions]], property
attributes (specified as scenario.attribute) or another logical expression.
When you combine logical operations to a more complex expression, the
operators are evaluated from left to right. ''''a | b & c'''' is identical to
''''(a | b) & c''''. It's highly recommended that you always use brackets to
control the evaluation sequence. Currently, TaskJuggler does not support the
concept of operator precedence or right-left associativity. This may change in
the future.

An operand can also be just a number. 0 evaluates to false, all other numbers
to true. The logical expression can also be the special constants ''''@all''''
or ''''@none''''. The first always evaluates to true, the latter to false.

Date attributes needs special attention. Attributes like [[maxend]] can
be undefined. To use such an attribute in a comparison, you need to test for
the validity first. E. g. to compare the end date of the ''''plan''''
scenario with the ''''maxend'''' value use ''''isvalid(plan.maxend) &
(plan.end > plan.maxend)''''. The ''''&'''' and ''''|'''' operators are lazy.
If the result is already known after evaluation of the first operand, the second
operand will not be evaluated any more.
EOT
     )
  also(%w( functions ))
  example('LogicalExpression', '1')
end

#rule_macroObject



2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2673

def rule_macro
  pattern(%w( _macro $ID $MACRO ), lambda {
    if @scanner.macroDefined?(@val[1])
      warning('marco_redefinition', "Redefining macro #{@val[1]}")
    end
    @scanner.addMacro(TextParser::Macro.new(@val[1], @val[2],
                                            @sourceFileInfo[0]))
  })
  doc('macro', <<'EOT'
Defines a text fragment that can later be inserted by using the specified ID.
To insert the text fragment anywhere in the text you need to write ${ID}.The
body is not optional. It must be enclosed in square brackets. Macros can be
declared like this:

 macro FOO [ This text ]

If later ''''${FOO}'''' is found in the project file, it is expanded to
''''This text''''.

Macros may have arguments. Arguments are accessed with special macros with
numbers as names.  The number specifies the index of the argument.

 macro FOO [ This ${1} text ]

will expand to ''''This stupid text'''' if called as ''''${FOO "stupid"}''''.
Macros may call other macros. All macro arguments must be enclosed by double
quotes. In case the argument contains a double quote, it must be escaped by a
backslash (''''\'''').

User defined macro IDs should start with one uppercase letter as all
lowercase letter IDs are reserved for built-in macros.

To terminate the macro definition, the ''''<nowiki>]</nowiki>'''' must be the
last character in the line. If there are any other characters trailing it
(even spaces or comments) the ''''<nowiki>]</nowiki>'''' will not be
considered the end of the macro definition.

In macro calls the macro names can be prefixed by a question mark. In this
case the macro will expand to nothing if the macro is not defined. Otherwise
the undefined macro would be flagged with an error message.

The macro call

 ${?foo}

will expand to nothing if foo is undefined.
EOT
     )
  example('Macro-1')
end

#rule_moreAlternativesObject



2730
2731
2732
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2730

def rule_moreAlternatives
  commaListRule('!resourceId')
end

#rule_moreArgumentsObject



2734
2735
2736
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2734

def rule_moreArguments
  commaListRule('!argument')
end

#rule_moreBangsObject



2724
2725
2726
2727
2728
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2724

def rule_moreBangs
  optional
  repeatable
  singlePattern('_!')
end

#rule_moreChargeSetItemsObject



2738
2739
2740
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2738

def rule_moreChargeSetItems
  commaListRule('!chargeSetItem')
end

#rule_moreColumnDefObject



2742
2743
2744
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2742

def rule_moreColumnDef
  commaListRule('!columnDef')
end

#rule_moreDepTasksObject



2746
2747
2748
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2746

def rule_moreDepTasks
  commaListRule('!taskDep')
end

#rule_moreExportFormatsObject



2750
2751
2752
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2750

def rule_moreExportFormats
  commaListRule('!exportFormat')
end

#rule_moreJournalSortCriteriaObject



2754
2755
2756
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2754

def rule_moreJournalSortCriteria
  commaListRule('!journalSortCriterium')
end

#rule_moreListOfDaysObject



2758
2759
2760
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2758

def rule_moreListOfDays
  commaListRule('!weekDayInterval')
end

#rule_moreOutputFormatsObject



2762
2763
2764
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2762

def rule_moreOutputFormats
  commaListRule('!outputFormat')
end

#rule_morePredTasksObject



2770
2771
2772
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2770

def rule_morePredTasks
  commaListRule('!taskPred')
end

#rule_moreProjectIDsObject



2766
2767
2768
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2766

def rule_moreProjectIDs
  commaListRule('$ID')
end

#rule_moreSortCriteriaObject



2774
2775
2776
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2774

def rule_moreSortCriteria
  commaListRule('!sortNonTree')
end

#rule_moreTimeIntervalsObject



2778
2779
2780
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2778

def rule_moreTimeIntervals
  commaListRule('!timeInterval')
end

#rule_navigatorObject



2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2782

def rule_navigator
  pattern(%w( !navigatorHeader !navigatorBody ), lambda {
    @project['navigators'][@navigator.id] = @navigator
  })
  doc('navigator', <<'EOT'
Defines a navigator object with the specified ID. This object can be used in
reports to include a navigation bar with references to other reports.
EOT
        )
  example('navigator')
end

#rule_navigatorAttributesObject



2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2794

def rule_navigatorAttributes
  optional
  repeatable
  pattern(%w( _hidereport !logicalExpression ), lambda {
    @navigator.hideReport = @val[1]
  })
  doc('hidereport', <<'EOT'
This attribute can be used to exclude the reports that match the specified
[[logicalexpression|logical expression]] from the navigation bar.
EOT
        )
end

#rule_navigatorBodyObject



2807
2808
2809
2810
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2807

def rule_navigatorBody
  optional
  pattern(%w( _{ !navigatorAttributes _} ))
end

#rule_navigatorHeaderObject



2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2812

def rule_navigatorHeader
  pattern(%w( _navigator $ID ), lambda {
    if @project['navigators'][@val[1]]
      error('navigator_exists',
            "The navigator #{@val[1]} has already been defined.",
            @sourceFileInfo[0])
    end
    @navigator = Navigator.new(@val[1], @project)
  })
end

#rule_nikuReportObject



2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2872

def rule_nikuReport
  pattern(%w( !nikuReportHeader !nikuReportBody ), lambda {
    @property = nil
  })
  doc('nikureport', <<'EOT'
This report generates an XML file to be imported into the enterprise resource
management software Clarity(R) from Computer Associates(R). The files contains
allocation curves for the specified resources. All tasks with identical user
defined attributes ''''ClarityPID'''' and ''''ClarityPNAME'''' are bundled
into a Clarity project. The resulting XML file can be imported into Clarity
with the xog-in tool.
EOT
     )
  example('Niku')
end

#rule_nikuReportAttributesObject



2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2823

def rule_nikuReportAttributes
  optional
  repeatable

  pattern(%w( !formats ))
  pattern(%w( !headline ))
  pattern(%w( !hideresource ))
  pattern(%w( !hidetask ))

  pattern(%w( !numberFormat ), lambda {
    @property.set('numberFormat', @val[0])
  })

  pattern(%w( !reportEnd ))
  pattern(%w( !reportPeriod ))
  pattern(%w( !reportStart ))
  pattern(%w( !reportTitle ))

  pattern(%w( _timeoff $STRING $STRING ), lambda {
    @property.set('timeOffId', @val[1])
    @property.set('timeOffName', @val[2])
  })
  doc('timeoff.nikureport', <<EOF
Set the Clarity project ID and name that the vacation time will be reported to.
EOF
     )
  arg(1, 'ID', 'The Clarity project ID')
  arg(2, 'Name', 'The Clarity project name')
end

#rule_nikuReportBodyObject



2853
2854
2855
2856
2857
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2853

def rule_nikuReportBody
  pattern(%w( _{ !nikuReportAttributes _} ), lambda {

  })
end

#rule_nikuReportHeaderObject



2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2859

def rule_nikuReportHeader
  pattern(%w( _nikureport !optionalID $STRING ), lambda {
    newReport(@val[1], @val[2], :niku, @sourceFileInfo[0]) do
      @property.set('numberFormat', RealFormat.new(['-', '', '', '.', 2]))
    end
  })
  arg(1, 'file name', <<'EOT'
The name of the time sheet report file to generate. It must end with a .tji
extension, or use . to use the standard output channel.
EOT
     )
end

#rule_nodeIdObject



2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2888

def rule_nodeId
  pattern(%w( !idOrAbsoluteId !subNodeId ), lambda {
    case @property.typeSpec
    when :taskreport
      if (p1 = @project.task(@val[0])).nil?
        error('unknown_main_node',
              "Unknown task ID #{@val[0]}", @sourceFileInfo[0])
      end
      if @val[1]
        if (p2 = @project.resource(@val[1])).nil?
          error('unknown_sub_node',
                "Unknown resource ID #{@val[0]}", @sourceFileInfo[0])
        end
        return [ p2, p1 ]
      end
      return [ p1, nil ]
    when :resourcereport
      if (p1 = @project.task(@val[0])).nil?
        error('unknown_main_node',
              "Unknown task ID #{@val[0]}", @sourceFileInfo[0])
      end
      if @val[1]
        if (p2 = @project.resource(@val[1])).nil?
          error('unknown_sub_node',
                "Unknown resource ID #{@val[0]}", @sourceFileInfo[0])
        end
        return [ p2, p1 ]
      end
      return [ p1, nil ]
    end

    raise "Node list is not supported for this report type: " +
          "#{@property.typeSpec}"
  })
end

#rule_nodeIdListObject



2924
2925
2926
2927
2928
2929
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2924

def rule_nodeIdList
  listRule('moreNodeIdList', '!nodeId')
  pattern([ '_-' ], lambda {
    []
  })
end

#rule_nonZeroWorkingDurationObject



7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7647

def rule_nonZeroWorkingDuration
  pattern(%w( !workingDuration ), lambda {
    slots = @val[0]
    if slots <= 0
      error('working_duration_too_small',
            "Duration values must be at least " +
            "#{@project['scheduleGranularity'] / 60} minutes " +
            "(your timingresolution) long.")
    end
    slots
  })
end

#rule_numberObject



2931
2932
2933
2934
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2931

def rule_number
  singlePattern('$INTEGER')
  singlePattern('$FLOAT')
end

#rule_numberFormatObject



2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2936

def rule_numberFormat
  pattern(%w( _numberformat $STRING $STRING $STRING $STRING $INTEGER ),
      lambda {
    RealFormat.new(@val.slice(1, 5))
  })
  doc('numberformat',
      'These values specify the default format used for all numerical ' +
      'real values.')
  arg(1, 'negativeprefix', 'Prefix for negative numbers')
  arg(2, 'negativesuffix', 'Suffix for negative numbers')
  arg(3, 'thousandsep', 'Separator used for every 3rd digit')
  arg(4, 'fractionsep', 'Separator used to separate the fraction digits')
  arg(5, 'fractiondigits', 'Number of fraction digits to show')
end

#rule_operandObject



2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 2951

def rule_operand
  pattern(%w( _( !operation _) ), lambda {
    @val[1]
  })
  pattern(%w( _~ !operand ), lambda {
    operation = LogicalOperation.new(@val[1])
    operation.operator = '~'
    operation
  })

  pattern(%w( $ABSOLUTE_ID ), lambda {
    if @val[0].count('.') > 1
      error('operand_attribute',
            'Attributes must be specified as <scenarioID>.<attribute>',
            @sourceFileInfo[0])
    end
    scenario, attribute = @val[0].split('.')
    if (scenarioIdx = @project.scenarioIdx(scenario)).nil?
      error('operand_unkn_scen', "Unknown scenario ID #{scenario}",
            @sourceFileInfo[0])
    end
    # TODO: Do at least some basic sanity checks of the attribute is valid.
    LogicalAttribute.new(attribute, @project.scenario(scenarioIdx))
  })
  pattern(%w( !date ), lambda {
    LogicalOperation.new(@val[0])
  })
  pattern(%w( $ID !argumentList ), lambda {
    if @val[1].nil?
      unless @project['flags'].include?(@val[0])
        error('operand_unkn_flag', "Undeclared flag '#{@val[0]}'",
              @sourceFileInfo[0])
      end
      LogicalFlag.new(@val[0])
    else
      func = LogicalFunction.new(@val[0])
      res = func.setArgumentsAndCheck(@val[1])
      unless res.nil?
        error(*res)
      end
      func
    end
  })
  pattern(%w( $INTEGER ), lambda {
    LogicalOperation.new(@val[0])
  })
  pattern(%w( $FLOAT ), lambda {
    LogicalOperation.new(@val[0])
  })
  pattern(%w( $STRING ), lambda {
    LogicalOperation.new(@val[0])
  })
end

#rule_operationObject



3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3005

def rule_operation
  pattern(%w( !operand !operationChain ), lambda {
    operation = LogicalOperation.new(@val[0])
    if @val[1]
      # Further operators/operands create an operation tree.
      @val[1].each do |ops|
        operation = LogicalOperation.new(operation)
        operation.operator = ops[0]
        operation.operand2 = ops[1]
      end
    end
    operation
  })
  arg(0, 'operand', <<'EOT'
An operand can consist of a date, a text string, a [[functions|function]], a
property attribute or a numerical value. It can also be the name of a declared
flag.  Use the ''''scenario_id.attribute'''' notation to use an attribute of
the currently evaluated property. The scenario ID always has to be specified,
also for non-scenario specific attributes. This is necessary to distinguish
them from flags. See [[columnid]] for a list of available attributes. The use
of list attributes is not recommended. User defined attributes are available
as well.

An operand can be a negated operand by prefixing a ~ character or it can be
another logical expression enclosed in braces.
EOT
      )
end

#rule_operationChainObject



3034
3035
3036
3037
3038
3039
3040
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3034

def rule_operationChain
  optional
  repeatable
  pattern(%w( !operatorAndOperand), lambda {
    @val[0]
  })
end

#rule_operatorObject



3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3052

def rule_operator
  singlePattern('_|')
  descr('The \'or\' operator')

  singlePattern('_&')
  descr('The \'and\' operator')

  singlePattern('_>')
  descr('The \'greater than\' operator')

  singlePattern('_<')
  descr('The \'smaller than\' operator')

  singlePattern('_=')
  descr('The \'equal\' operator')

  singlePattern('_>=')
  descr('The \'greater-or-equal\' operator')

  singlePattern('_<=')
  descr('The \'smaller-or-equal\' operator')

  singlePattern('_!=')
  descr('The \'not-equal\' operator')
end

#rule_operatorAndOperandObject



3042
3043
3044
3045
3046
3047
3048
3049
3050
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3042

def rule_operatorAndOperand
  pattern(%w( !operator !operand), lambda{
    [ @val[0], @val[1] ]
  })
  arg(1, 'operand', <<'EOT'
An operand can consist of a date, a text string or a numerical value. It can also be the name of a declared flag. Finally, an operand can be a negated operand by prefixing a ~ character or it can be another operation enclosed in braces.
EOT
      )
end

#rule_optionalIDObject



3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3078

def rule_optionalID
  optional
  pattern(%w( $ID ), lambda {
    @val[0]
  })
  arg(0, 'id', <<"EOT"
An optional ID. If you ever want to reference this property, you must specify
your own unique ID. If no ID is specified, one will be automatically generated.
These IDs may become visible in reports, but may change at any time. You may
never rely on automatically generated IDs.
EOT
     )
end

#rule_optionalMinusObject



3092
3093
3094
3095
3096
3097
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3092

def rule_optionalMinus
  optional
  pattern(%w( _- ), lambda {
    true
  })
end

#rule_optionalPercentObject



3099
3100
3101
3102
3103
3104
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3099

def rule_optionalPercent
  optional
  pattern(%w( !number _% ), lambda {
    @val[0] / 100.0
  })
end

#rule_optionalScenarioIdColObject



3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3105

def rule_optionalScenarioIdCol
  optional
  pattern(%w( $ID_WITH_COLON ), lambda {
    if (@scenarioIdx = @project.scenarioIdx(@val[0])).nil?
      error('unknown_scenario_id', "Unknown scenario: #{@val[0]}",
            @sourceFileInfo[0])
    end
    @scenarioIdx
  })
end

#rule_optionalVersionObject



3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3117

def rule_optionalVersion
  optional
  pattern(%w( $STRING ), lambda {
    @val[0]
  })
  arg(0, 'version', <<"EOT"
An optional version ID. This can be something simple as "4.2" or an ID tag of
a revision control system. If not specified, it defaults to "1.0".
EOT
     )
end

#rule_outputFormatObject



3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3129

def rule_outputFormat
  pattern(%w( _csv ), lambda {
    :csv
  })
  descr(<<'EOT'
The report lists the resources and their respective values as
colon-separated-value (CSV) format. Due to the very simple nature of the CSV
format, only a small subset of features will be supported for CSV output.
Including tasks or listing multiple scenarios will result in very difficult to
read reports.
EOT
       )

  pattern(%w( _html ), lambda {
    :html
  })
  descr('Generate a web page (HTML file)')

  pattern(%w( _niku ), lambda {
    :niku
  })
  descr('Generate an XOG XML file to be used with Clarity.')
end

#rule_outputFormatsObject



3153
3154
3155
3156
3157
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3153

def rule_outputFormats
  pattern(%w( !outputFormat !moreOutputFormats ), lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_plusOrMinusObject



3159
3160
3161
3162
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3159

def rule_plusOrMinus
  singlePattern('_+')
  singlePattern('_-')
end

#rule_projectObject



3164
3165
3166
3167
3168
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3164

def rule_project
  pattern(%w( !projectProlog !projectDeclaration !properties . ), lambda {
    @val[1]
  })
end

#rule_projectBodyObject



3170
3171
3172
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3170

def rule_projectBody
  optionsRule('projectBodyAttributes')
end

#rule_projectBodyAttributesObject



3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3174

def rule_projectBodyAttributes
  repeatable
  optional

  pattern(%w( _alertlevels !alertLevelDefinitions ), lambda {
    if @val[1].length < 2
      error('too_few_alert_levels',
            'You must specify at least 2 different alert levels.',
            @sourceFileInfo[1])
    end
    levels = @project['alertLevels']
    levels.clear
    @val[1].each do |level|
      if levels.indexById(level[0])
        error('alert_level_redef',
              "Alert level '#{level[0]}' has been defined multiple times.",
              @sourceFileInfo[1])
      end

      if levels.indexByName(level[1])
        error('alert_name_redef',
              "Alert level name '#{level[1]}' has been defined multiple " +
              "times.", @sourceFileInfo[1])
      end

      @project['alertLevels'].add(AlertLevelDefinition.new(*level))
    end
  })
  level(:beta)
  doc('alertlevels', <<'EOT'
By default TaskJuggler supports the pre-defined alert levels: green, yellow
and red. This attribute can be used to replace them with your own set of alert
levels. You can define any number of levels, but you need to define at least
two and they must be specified in ascending order from the least severity to
highest severity. Additionally, you need to provide a 15x15 pixel image file
with the name ''''flag-X.png'''' for each level where ''''X'''' matches the ID
of the alert level. These files need to be in the ''''icons'''' directory to
be found by the browser when showing HTML reports.
EOT
     )
  example('AlertLevels')

  pattern(%w( !currencyFormat ), lambda {
    @project['currencyFormat'] = @val[0]
  })

  pattern(%w( _currency $STRING ), lambda {
    @project['currency'] = @val[1]
  })
  doc('currency', 'The default currency unit.')
  example('Account')
  arg(1, 'symbol', 'Currency symbol')

  pattern(%w( _dailyworkinghours !number ), lambda {
    @project['dailyworkinghours'] = @val[1]
  })
  doc('dailyworkinghours', <<'EOT'
Set the average number of working hours per day. This is used as
the base to convert working hours into working days. This affects
for example the length task attribute. The default value is 8 hours
and should work for most Western countries. The value you specify should match
the settings you specified as your default [[workinghours.project|working
hours]].
EOT
     )
  example('Project')
  arg(1, 'hours', 'Average number of working hours per working day')

  pattern(%w( _extend !extendProperty !extendBody ), lambda {
    updateParserTables
  })
  doc('extend', <<'EOT'
Often it is desirable to collect more information in the project file than is
necessary for task scheduling and resource allocation. To add such information
to tasks, resources or accounts, the user can extend these properties with
user-defined attributes. The new attributes can be of various types such as
text, date or reference to capture various types of data. Optionally the user
can specify if the attribute value should be inherited from the enclosing
property.
EOT
     )
  example('CustomAttributes')

  pattern(%w( !projectBodyInclude ))

  pattern(%w( !journalEntry ))

  pattern(%w( _now !date ), lambda {
    @project['now'] = @val[1]
    @scanner.addMacro(TextParser::Macro.new('now', @val[1].to_s,
                                            @sourceFileInfo[0]))
    @scanner.addMacro(TextParser::Macro.new(
      'today', @val[1].to_s(@project['timeFormat']), @sourceFileInfo[0]))
  })
  doc('now', <<'EOT'
Specify the date that TaskJuggler uses for calculation as current
date. If no value is specified, the current value of the system
clock is used.
EOT
     )
  arg(1, 'date', 'Alternative date to be used as current date for all ' +
      'computations')

  pattern(%w( _markdate !date ), lambda {
    @project['markdate'] = @val[1]
    @scanner.addMacro(TextParser::Macro.new('markdate', @val[1].to_s,
                                            @sourceFileInfo[0]))
    @scanner.addMacro(TextParser::Macro.new(
      'today', @val[1].to_s(@project['timeFormat']), @sourceFileInfo[0]))
  })
  doc('markdate', <<'EOT'
Specify the reference date that TaskJuggler uses as date that can be specified
and set by the user. It can be used as additional point in time to help with
tracking tasks. If no value is specified, the current value of the system clock is used.
EOT
     )
  arg(1, 'date', 'Alternative date to be used as custom date specified by the user')

  pattern(%w( !numberFormat ), lambda {
    @project['numberFormat'] = @val[0]
  })

  pattern(%w( _outputdir $STRING ), lambda {
    # Directory name must be terminated by a slash.
    if @val[1].empty?
      error('outdir_empty', 'Output directory may not be empty.')
    end
    if !File.directory?(@val[1])
      error('outdir_missing',
            "Output directory '#{@val[1]}' does not exist or is not " +
            "a directory!")
    end
    @project.outputDir = @val[1] + (@val[1][-1] == ?/ ? '' : '/')
  })
  doc('outputdir',
      'Specifies the directory into which the reports should be generated. ' +
      'This will not affect reports whose name start with a slash. This ' +
      'setting can be overwritten by the command line option -o or --output-dir.')
  arg(1, 'directory', 'Path to an existing directory')

  pattern(%w( !scenario ))
  pattern(%w( _shorttimeformat $STRING ), lambda {
    @project['shortTimeFormat'] = @val[1]
  })
  doc('shorttimeformat',
      'Specifies time format for short time specifications. This is normal ' +
      'just hours and minutes.')
  arg(1, 'format', 'strftime like format string')

  pattern(%w( !timeformat ), lambda {
    @project['timeFormat'] = @val[0]
  })

  pattern(%w( !timezone ), lambda {
    @val[0]
  })

  pattern(%w( _timingresolution $INTEGER _min ), lambda {
    goodValues = [ 5, 10, 15, 20, 30, 60 ]
    unless goodValues.include?(@val[1])
      error('bad_timing_res',
            "Timing resolution must be one of #{goodValues.join(', ')} min.",
            @sourceFileInfo[1])
    end
    if @val[1] > (Project.maxScheduleGranularity / 60)
      error('too_large_timing_res',
            'The maximum allowed timing resolution for the timezone is ' +
            "#{Project.maxScheduleGranularity / 60} minutes.",
            @sourceFileInfo[1])
    end
    @project['scheduleGranularity'] = @val[1] * 60
  })
  doc('timingresolution', <<'EOT'
Sets the minimum timing resolution. The smaller the value, the longer the
scheduling process lasts and the more memory the application needs. The
default and maximum value is 1 hour. The smallest value is 5 min.
This value is a pretty fundamental setting of TaskJuggler. It has a severe
impact on memory usage and scheduling performance. You should set this value
to the minimum required resolution. Make sure that all values that you specify
are aligned with the resolution.

Changing the timing resolution will reset the [[workinghours.project|working
hours]] to the default times. It's recommended that this is the very first
option in the project header section.

Do not use this option after you've set the time zone!
EOT
      )

  pattern(%w( _trackingscenario !scenarioId ), lambda {
    @project['trackingScenarioIdx'] = @val[1]
    # The tracking scenario and all child scenarios will always be scheduled
    # in projection mode.
    @project.scenario(@val[1]).all.each do |scenario|
      scenario.set('projection', true)
    end
  })
  doc('trackingscenario', <<'EOT'
Specifies which scenario is used to capture what actually has happened with
the project. All sub-scenarios of this scenario inherit the bookings of the
tracking scenario and may not have any bookings of their own. The tracking
scenario must also be specified to use time and status sheet reports.

The tracking scenario must be defined after all scenarios have been defined.

The tracking scenario and all scenarios derived from it will be scheduled in
projection mode. This means that the scheduler will only add bookings after
the current date or the date specified by [[now]]. It is assumed that all
allocations prior to this date have been provided as [[booking.task|
task bookings]] or [[booking.resource|resource bookings]].
EOT
     )
  example('TimeSheet1', '2')

  pattern(%w( _weekstartsmonday ), lambda {
    @project['weekStartsMonday'] = true
  })
  doc('weekstartsmonday',
      'Specify that you want to base all week calculation on weeks ' +
      'starting on Monday. This is common in many European countries.')

  pattern(%w( _weekstartssunday ), lambda {
    @project['weekStartsMonday'] = false
  })
  doc('weekstartssunday',
      'Specify that you want to base all week calculation on weeks ' +
      'starting on Sunday. This is common in the United States of America.')

  pattern(%w( !workinghoursProject ))
  pattern(%w( _yearlyworkingdays !number ), lambda {
    @project['yearlyworkingdays'] = @val[1]
  })
  doc('yearlyworkingdays', <<'EOT'
Specifies the number of average working days per year. This should correlate
to the specified workinghours and vacation. It affects the conversion of
working hours, working days, working weeks, working months and working years
into each other.

When public holidays and leaves are disregarded, this value should be equal
to the number of working days per week times 52.1428 (the average number of
weeks per year). E. g. for a culture with 5 working days it is 260.714 (the
default), for 6 working days it is 312.8568 and for 7 working days it is
365.
EOT
     )
  arg(1, 'days', 'Number of average working days for a year')
end

#rule_projectBodyIncludeObject



3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3508

def rule_projectBodyInclude
  pattern(%w( _include !includeFile !projectBodyAttributes . ))
  lastSyntaxToken(1)
  doc('include.project', <<'EOT'
Includes the specified file name as if its contents would be written
instead of the include property. When the included files contains other
include statements or report definitions, the filenames are relative to the file
where they are defined in.

This version of the include directive may only be used inside the [[project]]
header section. The included files must only contain content that may be
present in a project header section.
EOT
     )
end

#rule_projectDeclarationObject



3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3422

def rule_projectDeclaration
  pattern(%w( !projectHeader !projectBody ), lambda {
    # If the user has specified a tracking scenario, we mark all children of
    # that scenario to disallow own bookings. These scenarios will inherit
    # their bookings from the tracking scenario.
    if (idx = @project['trackingScenarioIdx'])
      @project.scenario(idx).allLeaves(true).each do |scenario|
        scenario.set('ownbookings', false)
      end
    end
    @val[0]
  })
  doc('project', <<'EOT'
The project property is mandatory and should be the first property
in a project file. It is used to capture basic attributes such as
the project id, name and the expected time frame.

Be aware that the dates for the project period default to UTC times. See [[interval2]] for details.
EOT
     )
end

#rule_projectHeaderObject



3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3444

def rule_projectHeader
  pattern(%w( _project !optionalID $STRING !optionalVersion !interval ), lambda {
    @project = Project.new(@val[1], @val[2], @val[3])
    @project['start'] = @val[4].start
    @project['end'] = @val[4].end
    @projectId = @val[1]
    setGlobalMacros
    @property = nil
    @reportCounter = 0
    @project
  })
  arg(2, 'name', 'The name of the project')
end

#rule_projectIDsObject



3458
3459
3460
3461
3462
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3458

def rule_projectIDs
  pattern(%w( $ID !moreProjectIDs ), lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_projectionObject



3464
3465
3466
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3464

def rule_projection
  optionsRule('projectionAttributes')
end

#rule_projectionAttributesObject



3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3468

def rule_projectionAttributes
  optional
  repeatable
  pattern(%w( _sloppy ))
  level(:deprecated)
  also('trackingscenario')
  doc('sloppy.projection', '')

  pattern(%w( _strict ), lambda {
    warning('projection_strict',
            'The strict mode is now always used.')
  })
  level(:deprecated)
  also('trackingscenario')
  doc('strict.projection', '')
end

#rule_projectPrologObject



3485
3486
3487
3488
3489
3490
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3485

def rule_projectProlog
  optional
  repeatable
  pattern(%w( !prologInclude ))
  pattern(%w( !macro ))
end

#rule_projectPropertiesObject



3492
3493
3494
3495
3496
3497
3498
3499
3500
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3492

def rule_projectProperties
  # This rule is not defining actual syntax. It's only used for the
  # documentation.
  pattern(%w( !projectPropertiesBody ))
  doc('properties', <<'EOT'
The project properties. Every project must consist of at least one task. The other properties are optional. To save the scheduled data at least one output generating property should be used.
EOT
     )
end

#rule_projectPropertiesBodyObject



3502
3503
3504
3505
3506
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3502

def rule_projectPropertiesBody
  # This rule is not defining actual syntax. It's only used for the
  # documentation.
  optionsRule('properties')
end

#rule_prologIncludeObject



3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3524

def rule_prologInclude
  pattern(%w( _include !includeFile !projectProlog . ))
  lastSyntaxToken(1)
  doc('include.macro', <<'EOT'
Includes the specified file name as if its contents would be written
instead of the include property. The only exception is the include
statement itself. When the included files contains other include
statements or report definitions, the filenames are relative to the file
where they are defined in.

The included file may only contain macro definitions. This version of the
include directive can only be used before the [[project]] header.
EOT
     )
end

#rule_propertiesObject



3540
3541
3542
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3540

def rule_properties
  pattern(%w( !propertiesBody ))
end

#rule_propertiesBodyObject



3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3544

def rule_propertiesBody
  repeatable
  optional

  pattern(%w( !account ))

  pattern(%w( _auxdir $STRING ), lambda {
    auxdir = @val[1]
    # Ensure that the directory always ends with a '/'.
    auxdir += '/' unless auxdir[-1] == ?/
    @project['auxdir'] = auxdir
  })
  level(:beta)
  doc('auxdir', <<'EOT'
Specifies an alternative directory for the auxiliary report files such as CSS,
JavaScript and icon files. This setting will affect all subsequent report
definitions unless it gets overridden. If this attribute is not set, the
directory and its contents will be generated automatically. If this attribute
is provided, the user has to ensure that the directory exists and is filled
with the proper data. The specified path can be absolute or relative to the
generated report file.
EOT
     )

  pattern(%w( _copyright $STRING ), lambda {
    @project['copyright'] = @val[1]
  })
  doc('copyright', <<'EOT'
Set a copyright notice for the project file and its content. This copyright notice will be added to all reports that can support it.
EOT
     )
  example('Caption', '2')

  pattern(%w( !balance ), lambda {
    @project['costaccount'] = @val[0][0]
    @project['revenueaccount'] = @val[0][1]
  })

  pattern(%w( _flags !declareFlagList ), lambda {
    unless @project['flags'].include?(@val[1])
      @project['flags'] += @val[1]
    end
  })
  doc('flags', <<'EOT'
Declare one or more flag for later use. Flags can be used to mark tasks, resources or other properties to filter them in reports.
EOT
     )

  pattern(%w( !propertiesInclude ))

  pattern(%w( !leaves ), lambda {
    @val[0].each do |v|
      @project['leaves'] << v
    end
  })

  pattern(%w( !limits ), lambda {
    @project['limits'] = @val[0]
  })
  doc('limits', <<'EOT'
Set per-interval allocation limits for the following resource definitions.
The limits can be overwritten in each resource definition and the global
limits can be changed later.
EOT
     )

  pattern(%w( !macro ))

  pattern(%w( !navigator ))

  pattern(%w( _projectid $ID ), lambda {
    @project['projectids'] << @val[1]
    @project['projectids'].uniq!
    @project['projectid'] = @projectId = @val[1]
  })
  doc('projectid', <<'EOT'
This declares a new project id and activates it. All subsequent
task definitions will inherit this ID. The tasks of a project can have
different IDs.  This is particularly helpful if the project is merged from
several sub projects that each have their own ID.
EOT
     )

  pattern(%w( _projectids !projectIDs ), lambda {
    @project['projectids'] += @val[1]
    @project['projectids'].uniq!
  })
  doc('projectids', <<'EOT'
Declares a list of project IDs. When an include file that was generated from another project brings different project IDs, these need to be declared first.
EOT
      )

  pattern(%w( _rate !number ), lambda {
    @project['rate'] = @val[1].to_f
  })
  doc('rate', <<'EOT'
Set the default rate for all subsequently defined resources. The rate describes the daily cost of a resource.
EOT
      )

  pattern(%w( !reportProperties ))
  pattern(%w( !resource ))
  pattern(%w( !shift ))
  pattern(%w( !statusSheet ))

  pattern(%w( _supplement !supplement ))
  doc('supplement', <<'EOT'
The supplement keyword provides a mechanism to add more attributes to already
defined accounts, tasks or resources. The additional attributes must obey the
same rules as in regular task or resource definitions and must be enclosed by
curly braces.

This construct is primarily meant for situations where the information about a
task or resource is split over several files. E. g. the vacation dates for the
resources may be in a separate file that was generated by some other tool.
EOT
     )
  example('Supplement')

  pattern(%w( !task ))
  pattern(%w( !timeSheet ))
  pattern(%w( _vacation !vacationName !intervals ), lambda {
    @val[2].each do |interval|
      @project['leaves'] << Leave.new(:holiday, interval)
    end
  })
  doc('vacation', <<'EOT'
Specify a global vacation period for all subsequently defined resources. A
vacation can also be used to block out the time before a resource joined or
after it left. For employees changing their work schedule from full-time to
part-time, or vice versa, please refer to the 'Shift' property.
EOT
     )
  arg(1, 'name', 'Name or purpose of the vacation')
end

#rule_propertiesFileObject



3680
3681
3682
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3680

def rule_propertiesFile
  pattern(%w( !propertiesBody . ))
end

#rule_propertiesIncludeObject



3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3684

def rule_propertiesInclude
  pattern(%w( _include !includeProperties !properties . ), lambda {
  })
  lastSyntaxToken(1)
  doc('include.properties', <<'EOT'
Includes the specified file name as if its contents would be written
instead of the include property. The only exception is the include
statement itself. When the included files contains other include
statements or report definitions, the filenames are relative to the file
where they are defined in. include commands can be used in the project
header, at global scope or between property declarations of tasks,
resources, and accounts.

For technical reasons you have to supply the optional pair of curly
brackets if the include is followed immediately by a macro call that
is defined within the included file.
EOT
     )
end

#rule_purgeObject



3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3704

def rule_purge
  pattern(%w( _purge !optionalScenarioIdCol $ID ), lambda {
    attrId = @val[2]
    if (attributeDefinition = @property.attributeDefinition(attrId)).nil?
      error('purge_unknown_id',
            "#{attrId} is not a known attribute for this property",
            @sourceFileInfo[2])
    end
    if attributeDefinition.scenarioSpecific
      @scenarioIdx = 0 unless @val[1]
    else
      if @val[1]
        error('purge_non_sc_spec_attr',
              'Scenario specified for a non-scenario specific attribute')
      end
    end
    if @property.attributeDefinition(attrId).scenarioSpecific
      @property.getAttribute(attrId, @scenarioIdx).reset
    else
      @property.getAttribute(attrId).reset
    end
  })
  doc('purge', <<'EOT'
Many attributes inherit their values from the enclosing property or the global
scope. In certain circumstances, this is not desirable, e. g. for list
attributes. A list attribute is any attribute that takes a comma separated
list of values as argument. [[allocate]] and [[flags.task]] are
good examples of commonly used list attributes. By defining values for
such a list attribute in a nested property, the new values will be appended to
the list that was inherited from the enclosing property. The purge
attribute resets any attribute to its default value. A subsequent definition
for the attribute within the property will then add their values to an empty
list. The value of the enclosing property is not affected by purge.

For scenario specific attributes, an optional scenario ID can be specified
before the attribute ID. If it's missing, the default (first) scenario will be
used.
EOT
     )
  arg(1, 'attribute', 'Any name of a list attribute')
end

#rule_referenceAttributesObject



3746
3747
3748
3749
3750
3751
3752
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3746

def rule_referenceAttributes
  optional
  repeatable
  pattern(%w( _label $STRING ), lambda {
    @val[1]
  })
end

#rule_referenceBodyObject



3754
3755
3756
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3754

def rule_referenceBody
  optionsRule('referenceAttributes')
end

#rule_relativeIdObject



3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3758

def rule_relativeId
  pattern(%w( _! !moreBangs !idOrAbsoluteId ), lambda {
    str = '!'
    if @val[1]
      @val[1].each { |bang| str += bang }
    end
    str += @val[2]
    str
  })
end

#rule_reportableAttributesObject



3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3779

def rule_reportableAttributes
  singlePattern('_activetasks')
  descr(<<'EOT'
The number of sub-tasks (including the current task) that are active in the
reported time period. Active means that they are ongoing at the current time
or [[now]] date.
EOT
       )

  singlePattern('_annualleave')
  descr(<<'EOT'
The number of annual leave units within the reported time period. The unit
can be adjusted with [[loadunit]].
EOT
       )

  singlePattern('_annualleavebalance')
  descr(<<'EOT'
The balance of the annual leave at the end of the reporting interval. The unit
can be adjusted with [[loadunit]].
EOT
       )

  singlePattern('_annualleavelist')
  descr(<<'EOT'
A list with all annual leave intervals. The list can be customized with the
[[listtype.column|listtype]] attribute.
EOT
       )

  singlePattern('_alert')
  descr(<<'EOT'
The alert level of the property that was reported with the date closest to the
end date of the report. Container properties that don't have their own alert
level reported with a date equal or newer than the alert levels of all their
sub properties will get the highest alert level of their direct sub
properties.
EOT
       )

  singlePattern('_alertmessages')
  level(:deprecated)
  also('journal')
  descr('Deprecated. Please use ''''journal'''' instead')

  singlePattern('_alertsummaries')
  level(:deprecated)
  also('journal')
  descr('Deprecated. Please use ''''journal'''' instead')

  singlePattern('_alerttrend')
  descr(<<'EOT'
Shows how the alert level at the end of the report period compares to the
alert level at the beginning of the report period. Possible values are
''''Up'''', ''''Down'''' or ''''Flat''''.
EOT
       )

  singlePattern('_balance')
  descr(<<'EOT'
The account balance at the beginning of the reported period. This is the
balance before any transactions of the reported period have been credited.
EOT
       )

  singlePattern('_bsi')
  descr('The hierarchical or work breakdown structure index (i. e. 1.2.3)')

  singlePattern('_chart')
  descr(<<'EOT'
A Gantt chart. This column type requires all lines to have the same fixed
height. This does not work well with rich text columns in some browsers. Some
show a scrollbar for the compressed table cells, others don't. It is
recommended, that you don't use rich text columns in conjuction with the chart
column.
EOT
       )

  singlePattern('_children')
  descr(<<'EOT'
A list of all direct sub elements.

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attributes.
EOT
       )

  singlePattern('_closedtasks')
  descr(<<'EOT'
The number of sub-tasks (including the current task) that have been closed
during the reported time period.  Closed means that they have an end date
before the current time or [[now]] date.
EOT
       )

  singlePattern('_competitorcount')
  descr(<<'EOT'
The number of tasks that have successfully competed for the same resources and
have potentially delayed the completion of this task.
EOT
       )
  singlePattern('_competitors')
  descr(<<'EOT'
A list of tasks that have successfully competed for the same resources and
have potentially delayed the completion of this task.
EOT
       )

  singlePattern('_complete')
  descr(<<'EOT'
The completion degree of a task. Unless a completion degree is manually
provided, this is a computed value relative to the [[now]] date of the project. A
task that has ended before the now date is always 100% complete. A task that
starts at or after the now date is always 0%. For [[effort]] based tasks the
computation degree is the percentage of done effort of the overall effort. For
other leaf tasks, the completion degree is the percentage of the already passed
duration of the overall task duration. For container tasks, it's always the
average of the direct sub tasks. If the sub tasks consist of a mixture of
effort and non-effort tasks, the completion value is only of limited value.
EOT
       )

  pattern([ '_completed' ], lambda {
    'complete'
  })
  level(:deprecated)
  also('complete')
  descr('Deprecated alias for complete')

  singlePattern('_criticalness')
  descr('A measure for how much effort the resource is allocated for, or ' +
        'how strained the allocated resources of a task are.')

  singlePattern('_cost')
  descr(<<'EOT'
The cost of the task or resource. The use of this column requires that a cost
account has been set for the report using the [[balance]] attribute.
EOT
       )

  singlePattern('_daily')
  descr('A group of columns with one column for each day')

  singlePattern('_directreports')
  descr(<<'EOT'
The resources that have this resource assigned as manager.

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attribute.
EOT
       )

  singlePattern('_duration')
  descr('The duration of a task')

  singlePattern('_duties')
  descr('List of tasks that the resource is allocated to')

  singlePattern('_efficiency')
  descr('Measure for how efficient a resource can perform tasks')

  singlePattern('_effort')
  descr('The allocated effort during the reporting period')

  singlePattern('_effortdone')
  descr('The already completed effort as of now')

  singlePattern('_effortleft')
  descr('The remaining allocated effort as of now')

  singlePattern('_email')
  descr('The email address of a resource')

  singlePattern('_end')
  descr('The end date of a task')

  singlePattern('_flags')
  descr('List of attached flags')

  singlePattern('_followers')
  descr(<<'EOT'
A list of tasks that depend on the current task. The list contains the names,
the IDs, the date and the type of dependency. For the type the following
symbols are used for <nowiki><dep></nowiki>:

* '''<nowiki>]->[</nowiki>''': End-to-Start dependency
* '''<nowiki>[->[</nowiki>''': Start-to-Start dependency
* '''<nowiki>]->]</nowiki>''': End-to-End dependency
* '''<nowiki>[->]</nowiki>''': Start-to-End dependency

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column]] attributes. The dependency symbol can be generated via
the ''''dependency'''' attribute in the query, the target date via the
''''date'''' attribute.
EOT
       )

  singlePattern('_freetime')
  descr(<<'EOT'
The amount of unallocated work time of a resource during the reporting period.
EOT
       )

  singlePattern('_freework')
  descr(<<'EOT'
The amount of unallocated work capacity of a resource during the reporting
period. This is the product of unallocated work time times the efficiency of
the resource.
EOT
       )

  singlePattern('_fte')
  descr(<<'EOT'
The Full-Time-Equivalent of a resource or group. This is the ratio of the
resource working time and the global working time. Working time is defined by
working hours and leaves. The FTE value can vary over time and is
calculated for the report interval or the user specified interval.
EOT
       )

  singlePattern('_gauge')
  descr(<<'EOT'
When [[complete]] values have been provided to capture the actual progress on
tasks, the gauge column will list whether the task is ahead of, behind or on
schedule.
EOT
       )

  singlePattern('_headcount')
  descr(<<'EOT'
For resources this is the headcount number of the resource or resource group.
For a single resource this is the [[efficiency]] rounded to the next integer.
Resources that are marked as unemployed at the report start time are not
counted. For a group it is the sum of the sub resources headcount.

For tasks it's the number of different resources allocated to the task during
the report interval. Resources are weighted with their rounded efficiencies.
EOT
       )

  pattern([ '_hierarchindex' ], lambda {
    'bsi'
  })
  level(:deprecated)
  also('bsi')
  descr('Deprecated alias for bsi')

  singlePattern('_hourly')
  descr('A group of columns with one column for each hour')

  singlePattern('_id')
  descr('The id of the item')

  singlePattern('_index')
  descr('The index of the item based on the nesting hierachy')

  singlePattern('_inputs')
  descr(<<'EOT'
A list of milestones that are a prerequiste for the current task. For
container tasks it will also include the inputs of the child tasks. Inputs may
not have any predecessors.

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attribute.
EOT
       )

  singlePattern('_journal')
  descr(<<'EOT'
The journal entries for the task or resource for the reported interval. The
generated text can be customized with [[journalmode]],
[[journalattributes]], [[hidejournalentry]] and [[sortjournalentries]]. If
used in queries without a property context, the journal for the complete
project is generated.
EOT
       )

  singlePattern('_journal_sub')
  level(:deprecated)
  also('journal')
  descr('Deprecated. Please use ''''journal'''' instead')

  singlePattern('_journalmessages')
  level(:deprecated)
  also('journal')
  descr('Deprecated. Please use ''''journal'''' instead')

  singlePattern('_journalsummaries')
  level(:deprecated)
  also('journal')
  descr('Deprecated. Please use ''''journal'''' instead')

  singlePattern('_line')
  descr('The line number in the report')

  singlePattern('_managers')
  descr(<<'EOT'
A list of managers that the resource reports to.

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attributes.
EOT
      )

  singlePattern('_maxend')
  descr('The latest allowed end of a task')

  singlePattern('_maxstart')
  descr('The lastest allowed start of a task')

  singlePattern('_minend')
  descr('The earliest allowed end of a task')

  singlePattern('_minstart')
  descr('The earliest allowed start of a task')

  singlePattern('_monthly')
  descr('A group of columns with one column for each month')

  singlePattern('_no')
  descr('The object line number in the report (Cannot be used for sorting!)')

  singlePattern('_name')
  descr('The name or description of the item')

  singlePattern('_note')
  descr('The note attached to a task')

  singlePattern('_opentasks')
  descr(<<'EOT'
The number of sub-tasks (including the current task) that have not yet been
closed during the reported time period. Closed means that they have an end
date before the current time or [[now]] date.
EOT
       )

  singlePattern('_pathcriticalness')
  descr('The criticalness of the task with respect to all the paths that ' +
        'it is a part of.')

  singlePattern('_precursors')
  descr(<<'EOT'
A list of tasks the current task depends on. The list contains the names, the
IDs, the date and the type of dependency. For the type the following symbols
are used

* '''<nowiki>]->[</nowiki>''': End-to-Start dependency
* '''<nowiki>[->[</nowiki>''': Start-to-Start dependency
* '''<nowiki>]->]</nowiki>''': End-to-End dependency
* '''<nowiki>[->]</nowiki>''': Start-to-End dependency

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attributes.  The dependency symbol can be
generated via the ''''dependency'''' attribute in the query, the target date
via the ''''date'''' attribute.
EOT
       )

  singlePattern('_priority')
  descr('The priority of a task')

  singlePattern('_quarterly')
  descr('A group of columns with one column for each quarter')

  singlePattern('_rate')
  descr('The daily cost of a resource.')

  singlePattern('_reports')
  descr(<<'EOT'
All resources that have this resource assigned as a direct or indirect manager.

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attributes.
EOT
       )

  singlePattern('_resources')
  descr(<<'EOT'
A list of resources that are assigned to the task in the report time frame.

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attributes.
EOT
       )

  singlePattern('_responsible')
  descr(<<'EOT'
The responsible people for this task.

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attributes.
EOT
       )

  singlePattern('_revenue')
  descr(<<'EOT'
The revenue of the task or resource. The use of this column requires that a
revenue account has been set for the report using the [[balance]] attribute.
EOT
       )

  singlePattern('_scenario')
  descr('The name of the scenario')

  singlePattern('_scheduling')
  descr(<<'EOT'
The scheduling mode of the leaf tasks. ASAP tasks are scheduled start to end while ALAP tasks are scheduled end to start.
EOT
       )

  singlePattern('_seqno')
  descr('The index of the item based on the declaration order')

  singlePattern('_sickleave')
  descr(<<'EOT'
The number of sick leave units within the reported time period. The unit can
be adjusted with [[loadunit]].
EOT
       )

  singlePattern('_specialleave')
  descr(<<'EOT'
The number of special leave units within the reported time period. The unit
can be adjusted with [[loadunit]].
EOT
       )

  singlePattern('_start')
  descr('The start date of the task')

  singlePattern('_status')
  descr(<<'EOT'
The status of a task. It is determined based on the current date or the date
specified by [[now]].
EOT
       )

  singlePattern('_targets')
  descr(<<'EOT'
A list of milestones that depend on the current task. For container tasks it
will also include the targets of the child tasks. Targets may not have any
follower tasks.

The list can be customized by the [[listitem.column|listitem]] and
[[listtype.column|listtype]] attributes.
EOT
       )

  singlePattern('_turnover')
  descr(<<'EOT'
The financial turnover of an account during the reporting interval.
EOT
       )

  pattern([ '_wbs' ], lambda {
    'bsi'
  })
  level(:deprecated)
  also('bsi')
  descr('Deprecated alias for bsi.')

  singlePattern('_unpaidleave')
  descr(<<'EOT'
The number of unpaid leave units within the reported time period. The unit
can be adjusted with [[loadunit]].
EOT
       )

  singlePattern('_weekly')
  descr('A group of columns with one column for each week')

  singlePattern('_yearly')
  descr('A group of columns with one column for each year')

end

#rule_reportAttributesObject



4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4255

def rule_reportAttributes
  optional
  repeatable

  pattern(%w( _accountroot !accountId), lambda {
    if @val[1].leaf?
      error('accountroot_leaf',
            "#{@val[1].fullId} is not a container account",
            @sourceFileInfo[1])
    end
    @property.set('accountroot', @val[1])
  })
  doc('accountroot', <<'EOT'
Only accounts below the specified root-level accounts are exported. The exported
accounts will have the ID of the root-level account stripped from their ID, so that
the sub-accounts of the root-level account become top-level accounts in the report
file.
EOT
     )
  example('AccountReport')

  pattern(%w( _auxdir $STRING ), lambda {
    auxdir = @val[1]
    # Ensure that the directory always ends with a '/'.
    auxdir += '/' unless auxdir[-1] == ?/
    @property.set('auxdir', auxdir)
  })
  level(:beta)
  doc('auxdir.report', <<'EOT'
Specifies an alternative directory for the auxiliary report files such as CSS,
JavaScript and icon files. If this attribute is not set, the directory will be
generated automatically. If this attribute is provided, the user has to ensure
that the directory exists and is filled with the proper data. The specified
path can be absolute or relative to the generated report file.
EOT
     )

  pattern(%w( !balance ), lambda {
    @property.set('costaccount', @val[0][0])
    @property.set('revenueaccount', @val[0][1])
  })

  pattern(%w( _caption $STRING ), lambda {
    @property.set('caption', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('caption', <<'EOT'
The caption will be embedded in the footer of the table or data segment. The
text will be interpreted as [[Rich_Text_Attributes|Rich Text]].
EOT
     )
  arg(1, 'text', 'The caption text.')
  example('Caption', '1')

  pattern(%w( _center $STRING ), lambda {
    @property.set('center', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('center', <<'EOT'
This attribute defines the center section of the [[textreport]]. The text will
be interpreted as [[Rich_Text_Attributes|Rich Text]].
EOT
     )
  arg(1, 'text', 'The text')
  example('textreport')

  pattern(%w( _columns !columnDef !moreColumnDef ), lambda {
    columns = [ @val[1] ]
    columns += @val[2] if @val[2]
    @property.set('columns', columns)
  })
  doc('columns', <<'EOT'
Specifies which columns shall be included in a report. Some columns show
values that are constant over the course of the project. Other columns show
calculated values that depend on the time period that was chosen for the
report.
EOT
     )

  pattern(%w( !currencyFormat ), lambda {
    @property.set('currencyFormat', @val[0])
  })

  pattern(%w( !reportEnd ))

  pattern(%w( _epilog $STRING ), lambda {
    @property.set('epilog', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('epilog', <<'EOT'
Define a text section that is printed right after the actual report data. The
text will be interpreted as [[Rich_Text_Attributes|Rich Text]].
EOT
     )
  also(%w( footer header prolog ))

  pattern(%w( !flags ))
  doc('flags.report', <<'EOT'
Attach a set of flags. The flags can be used in logical expressions to filter
properties from the reports.
EOT
     )

  pattern(%w( _footer $STRING ), lambda {
    @property.set('footer', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('footer', <<'EOT'
Define a text section that is put at the bottom of the report. The
text will be interpreted as [[Rich_Text_Attributes|Rich Text]].
EOT
     )
  example('textreport')
  also(%w( epilog header prolog ))

  pattern(%w( !formats ))

  pattern(%w( _header $STRING ), lambda {
    @property.set('header', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('header', <<'EOT'
Define a text section that is put at the top of the report. The
text will be interpreted as [[Rich_Text_Attributes|Rich Text]].
EOT
     )
  example('textreport')
  also(%w( epilog footer prolog ))

  pattern(%w( !headline ))
  pattern(%w( !hidejournalentry ))
  pattern(%w( !hideaccount ))
  pattern(%w( !hideresource ))
  pattern(%w( !hidetask ))

  pattern(%w( _height $INTEGER ), lambda {
    if @val[1] < 200
      error('min_report_height',
            "The report must have a minimum height of 200 pixels.")
    end
    @property.set('height', @val[1])
  })
  doc('height', <<'EOT'
Set the height of the report in pixels. This attribute is only used for
reports that cannot determine the height based on the content. Such reports can
be freely resized to fit in. The vast majority of reports can determine their
height based on the provided content. These reports will simply ignore this
setting.
EOT
     )
  also('width')

  pattern(%w( !journalReportAttributes ))
  pattern(%w( _journalmode !journalReportMode ), lambda {
    @property.set('journalMode', @val[1])
  })
  doc('journalmode', <<'EOT'
This attribute controls what journal entries are aggregated into the report.
EOT
     )

  pattern(%w( _left $STRING ), lambda {
    @property.set('left', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('left', <<'EOT'
This attribute defines the left margin section of the [[textreport]]. The text
will be interpreted as [[Rich_Text_Attributes|Rich Text]]. The margin will not
span the [[header]] or [[footer]] sections.
EOT
     )
  example('textreport')

  pattern(%w( !loadunit ))

  pattern(%w( !numberFormat ), lambda {
    @property.set('numberFormat', @val[0])
  })

  pattern(%w( _opennodes !nodeIdList ), lambda {
    @property.set('openNodes', @val[1])
  })
  doc('opennodes', 'For internal use only!')

  pattern(%w( !reportPeriod ))

  pattern(%w( _prolog $STRING ), lambda {
    @property.set('prolog', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('prolog', <<'EOT'
Define a text section that is printed right before the actual report data. The
text will be interpreted as [[Rich_Text_Attributes|Rich Text]].
EOT
     )
  also(%w( epilog footer header ))

  pattern(%w( !purge ))

  pattern(%w( _rawhtmlhead $STRING ), lambda {
    @property.set('rawHtmlHead', @val[1])
  })
  doc('rawhtmlhead', <<'EOT'
Define an HTML fragment that will be inserted at the end of the HTML head
section.
EOT
     )

  pattern(%w( !reports ))

  pattern(%w( _right $STRING ), lambda {
    @property.set('right', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('right', <<'EOT'
This attribute defines the right margin section of the [[textreport]]. The text
will be interpreted as [[Rich_Text_Attributes|Rich Text]]. The margin will not
span the [[header]] or [[footer]] sections.
EOT
     )
  example('textreport')

  pattern(%w( !rollupaccount ))
  pattern(%w( !rollupresource ))
  pattern(%w( !rolluptask ))

  pattern(%w( _scenarios !scenarioIdList ), lambda {
    # Don't include disabled scenarios in the report
    @val[1].delete_if { |sc| !@project.scenario(sc).get('active') }
    @property.set('scenarios', @val[1])
  })
  doc('scenarios', <<'EOT'
List of scenarios that should be included in the report. By default, only the
top-level scenario will be included. You can use this attribute to include
data from the defined set of scenarios. Not all reports support reporting data
from multiple scenarios. They will only include data from the first one in the
list.
EOT
     )

  pattern(%w( _selfcontained !yesNo ), lambda {
    @property.set('selfcontained', @val[1])
  })
  doc('selfcontained', <<'EOT'
Try to generate selfcontained output files when the format supports this. E.
g. for HTML reports, the style sheet will be included and no icons will be
used.
EOT
     )

  pattern(%w( !sortAccounts ))
  pattern(%w( !sortJournalEntries ))
  pattern(%w( !sortResources ))
  pattern(%w( !sortTasks ))

  pattern(%w( !reportStart ))

  pattern(%w( _resourceroot !resourceId), lambda {
    if @val[1].leaf?
      error('resourceroot_leaf',
            "#{@val[1].fullId} is not a group resource",
            @sourceFileInfo[1])
    end
    @property.set('resourceroot', @val[1])
  })
  doc('resourceroot', <<'EOT'
Only resources below the specified root-level resources are exported. The
exported resources will have the ID of the root-level resource stripped from
their ID, so that the sub-resources of the root-level resource become
top-level resources in the report file.
EOT
     )
  example('ResourceRoot')

  pattern(%w( _taskroot !taskId), lambda {
    if @val[1].leaf?
      error('taskroot_leaf',
            "#{@val[1].fullId} is not a container task",
            @sourceFileInfo[1])
    end
    @property.set('taskroot', @val[1])
  })
  doc('taskroot', <<'EOT'
Only tasks below the specified root-level tasks are exported. The exported
tasks will have the ID of the root-level task stripped from their ID, so that
the sub-tasks of the root-level task become top-level tasks in the report
file.
EOT
     )
  example('TaskRoot')

  pattern(%w( !timeformat ), lambda {
    @property.set('timeFormat', @val[0])
  })

  pattern(%w( _timezone !validTimeZone ), lambda {
    @property.set('timezone', @val[1])
  })
  doc('timezone.report', <<'EOT'
Sets the time zone used for all dates in the report. This setting is ignored
if the report is embedded into another report. Embedded in this context means
the report is part of another generated report. It does not mean that the
report definition is a sub report of another report definition.
EOT
     )

  pattern(%w( !reportTitle ))

  pattern(%w( _width $INTEGER ), lambda {
    if @val[1] < 400
      error('min_report_width',
            "The report must have a minimum width of 400 pixels.")
    end
    @property.set('width', @val[1])
  })
  doc('width', <<'EOT'
Set the width of the report in pixels. This attribute is only used for
reports that cannot determine the width based on the content. Such reports can
be freely resized to fit in. The vast majority of reports can determine their
width based on the provided content. These reports will simply ignore this
setting.
EOT
     )
  also('height')
end

#rule_reportBodyObject



4686
4687
4688
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4686

def rule_reportBody
  optionsRule('reportAttributes')
end

#rule_reportEndObject



4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4573

def rule_reportEnd
  pattern(%w( _end !date ), lambda {
    if @val[1] < @property.get('start')
      error('report_end',
            "End date must be before start date #{@property.get('start')}",
            @sourceFileInfo[1])
    end
    @property.set('end', @val[1])
  })
  doc('end.report', <<'EOT'
Specifies the end date of the report. In task reports only tasks that start
before this end date are listed.
EOT
     )
  example('Export', '2')
end

#rule_reportIdObject



4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4589

def rule_reportId
  pattern(%w( !reportIdUnverifd ), lambda {
    id = @val[0]
    if @property && @property.is_a?(Report)
      id = @property.fullId + '.' + id
    else
      id = @reportprefix + '.' + id unless @reportprefix.empty?
    end
    # In case we have a nested supplement, we need to prepend the parent ID.
    if (report = @project.report(id)).nil?
      error('report_id_expected', "#{id} is not a defined report.",
            @sourceFileInfo[0])
    end
    report
  })
  arg(0, 'report', 'The ID of a defined report')
end

#rule_reportIdUnverifdObject



4607
4608
4609
4610
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4607

def rule_reportIdUnverifd
  singlePattern('$ABSOLUTE_ID')
  singlePattern('$ID')
end

#rule_reportNameObject



4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4612

def rule_reportName
  pattern(%w( $STRING ), lambda {
    @val[0]
  })
  arg(0, 'name', <<'EOT'
The name of the report. This will be the base name for generated output files.
The suffix will depend on the specified [[formats]]. It will also be used in
navigation bars.

By default, report definitions do not generate any files. With more complex
projects, most report definitions will be used to describe elements of
composed reports. If you want to generate a file from this report, you must
specify the list of [[formats]] that you want to generate. The report name
will then be used as a base name to create the file. The suffix will be
appended based on the generated format.

Reports have a local name space. All IDs and file names must be unique within
the reports that belong to the same enclosing report. To reference a report
for inclusion into another report, you need to specify the full report ID.
This is composed of the report ID, prefixed by a dot-separated list of all
parent report IDs.
EOT
     )
end

#rule_reportPeriodObject



4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4637

def rule_reportPeriod
  pattern(%w( _period !interval ), lambda {
    @property.set('start', @val[1].start)
    @property.set('end', @val[1].end)
  })
  doc('period.report', <<'EOT'
This property is a shortcut for setting the start and end property at the
same time.
EOT
     )
end

#rule_reportPropertiesObject



4649
4650
4651
4652
4653
4654
4655
4656
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4649

def rule_reportProperties
  pattern(%w( !iCalReport ))
  pattern(%w( !nikuReport ))
  pattern(%w( !reports ))
  pattern(%w( !tagfile ))
  pattern(%w( !statusSheetReport ))
  pattern(%w( !timeSheetReport ))
end

#rule_reportPropertiesBodyObject



4658
4659
4660
4661
4662
4663
4664
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4658

def rule_reportPropertiesBody
  optional
  repeatable

  pattern(%w( !macro ))
  pattern(%w( !reportProperties ))
end

#rule_reportPropertiesFileObject



4666
4667
4668
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4666

def rule_reportPropertiesFile
  pattern(%w( !reportPropertiesBody . ))
end

#rule_reportsObject



3770
3771
3772
3773
3774
3775
3776
3777
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 3770

def rule_reports
  pattern(%w( !accountReport ))
  pattern(%w( !export ))
  pattern(%w( !resourceReport ))
  pattern(%w( !taskReport ))
  pattern(%w( !textReport ))
  pattern(%w( !traceReport ))
end

#rule_reportStartObject



4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4670

def rule_reportStart
  pattern(%w( _start !date ), lambda {
    if @val[1] > @property.get('end')
      error('report_start',
            "Start date must be before end date #{@property.get('end')}",
            @sourceFileInfo[1])
    end
    @property.set('start', @val[1])
  })
  doc('start.report', <<'EOT'
Specifies the start date of the report. In task reports only tasks that end
after this end date are listed.
EOT
     )
end

#rule_reportTitleObject



4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4690

def rule_reportTitle
  pattern(%w( _title $STRING ), lambda {
    @property.set('title', @val[1])
  })
  doc('title', <<'EOT'
The title of the report will be used in external references to the report. It
will not show up in the reports directly. It's used e. g. by [[navigator]].
EOT
     )
end

#rule_resourceObject



4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4701

def rule_resource
  pattern(%w( !resourceHeader !resourceBody ), lambda {
     @property = @property.parent
  })
  doc('resource', <<'EOT'
Tasks that have an effort specification need to have at least one resource
assigned to do the work. Use this property to define resources or groups of
resources.

Resources have a global name space. All IDs must be unique within the resources
of the project.
EOT
     )
end

#rule_resourceAttributesObject



4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4716

def rule_resourceAttributes
  repeatable
  optional
  pattern(%w( _email $STRING ), lambda {
    @property.set('email', @val[1])
  })
  doc('email',
      'The email address of the resource.')

  pattern(%w( !journalEntry ))
  pattern(%w( !purge ))
  pattern(%w( !resource ))
  pattern(%w( !resourceScenarioAttributes ))
  pattern(%w( !scenarioIdCol !resourceScenarioAttributes ), lambda {
    @scenarioIdx = 0
  })

  pattern(%w( _supplement !resourceId !resourceBody ), lambda {
    @property = @idStack.pop
  })
  doc('supplement.resource', <<'EOT'
The supplement keyword provides a mechanism to add more attributes to already
defined resources. The additional attributes must obey the same rules as in
regular resource definitions and must be enclosed by curly braces.

This construct is primarily meant for situations where the information about a
resource is split over several files. E. g. the vacation dates for the
resources may be in a separate file that was generated by some other tool.
EOT
     )
  example('Supplement', 'resource')

  # Other attributes will be added automatically.
end

#rule_resourceBodyObject



4751
4752
4753
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4751

def rule_resourceBody
  optionsRule('resourceAttributes')
end

#rule_resourceBookingObject



4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4755

def rule_resourceBooking
  pattern(%w( !resourceBookingHeader !bookingBody ), lambda {
    unless @project.scenario(@scenarioIdx).get('ownbookings')
      error('no_own_resource_booking',
            "The scenario #{@project.scenario(@scenarioIdx).fullId} " +
            'inherits its bookings from the tracking ' +
            'scenario. You cannot specificy additional bookings for it.')
    end
    @val[0].task.addBooking(@scenarioIdx, @val[0])
  })
end

#rule_resourceBookingHeaderObject



4767
4768
4769
4770
4771
4772
4773
4774
4775
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4767

def rule_resourceBookingHeader
  pattern(%w( !taskId !valIntervals ), lambda {
    checkBooking(@val[0], @property)
    @booking = Booking.new(@property, @val[0], @val[1])
    @booking.sourceFileInfo = @sourceFileInfo[0]
    @booking
  })
  arg(0, 'id', 'Absolute ID of a defined task')
end

#rule_resourceHeaderObject



4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4789

def rule_resourceHeader
  pattern(%w( _resource !optionalID $STRING ), lambda {
    if @property.nil? && !@resourceprefix.empty?
      @property = @project.resource(@resourceprefix)
    end
    if @val[1] && @project.resource(@val[1])
      error('resource_exists',
            "Resource #{@val[1]} has already been defined.",
            @sourceFileInfo[1], @property)
    end
    @property = Resource.new(@project, @val[1], @val[2], @property)
    @property.sourceFileInfo = @sourceFileInfo[0]
    @property.inheritAttributes
    @scenarioIdx = 0
  })
#    arg(1, 'id', <<'EOT'
#The ID of the resource. Resources have a global name space. The ID must be
#unique within the whole project.
#EOT
#       )
  arg(2, 'name', 'The name of the resource')
end

#rule_resourceIdObject



4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4777

def rule_resourceId
  pattern(%w( $ID ), lambda {
    id = (@resourceprefix.empty? ? '' : @resourceprefix + '.') + @val[0]
    if (resource = @project.resource(id)).nil?
      error('resource_id_expected', "#{id} is not a defined resource.",
            @sourceFileInfo[0])
    end
    resource
  })
  arg(0, 'resource', 'The ID of a defined resource')
end

#rule_resourceLeafListObject



4812
4813
4814
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4812

def rule_resourceLeafList
  listRule('moreResourceLeafList', '!leafResourceId')
end

#rule_resourceListObject



4816
4817
4818
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4816

def rule_resourceList
  listRule('moreResources', '!undefResourceId')
end

#rule_resourceReportObject



4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4820

def rule_resourceReport
  pattern(%w( !resourceReportHeader !reportBody ), lambda {
    @property = @property.parent
  })
  doc('resourcereport', <<'EOT'
The report lists resources and their respective values in a table. The task
that the resources are allocated to can be listed as well. To reduce the
list of included resources, you can use the [[hideresource]],
[[rollupresource]] or [[resourceroot]] attributes. The order of the tasks can
be controlled with [[sortresources]]. If the first sorting criteria is tree
sorting, the parent resources will always be included to form the tree.
Tree sorting is the default. You need to change it if you do not want certain
parent resources to be included in the report.

By default, all the tasks that the resources are allocated to are hidden, but
they can be listed as well. Use the [[hidetask]] attribute to select which
tasks should be included.
EOT
     )
end

#rule_resourceReportHeaderObject



4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4841

def rule_resourceReportHeader
  pattern(%w( _resourcereport !optionalID !reportName ), lambda {
    newReport(@val[1], @val[2], :resourcereport, @sourceFileInfo[0]) do
      unless @property.modified?('columns')
        # Set the default columns for this report.
        %w( no name ).each do |col|
          @property.get('columns') <<
          TableColumnDefinition.new(col, columnTitle(col))
        end
      end
      # Show all resources, sorted by tree and id-up.
      unless @property.modified?('hideResource')
        @property.set('hideResource',
                      LogicalExpression.new(LogicalOperation.new(0)))
      end
      unless @property.modified?('sortResources')
        @property.set('sortResources', [ [ 'tree', true, -1 ],
                      [ 'id', true, -1 ] ])
      end
      # Hide all resources, but set sorting to tree, start-up, seqno-up.
      unless @property.modified?('hideTask')
        @property.set('hideTask',
                      LogicalExpression.new(LogicalOperation.new(1)))
      end
      unless @property.modified?('sortTasks')
        @property.set('sortTasks',
                      [ [ 'tree', true, -1 ],
                        [ 'start', true, 0 ],
                        [ 'seqno', true, -1 ] ])
      end
    end
  })
end

#rule_resourceScenarioAttributesObject



4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 4875

def rule_resourceScenarioAttributes
  pattern(%w( !chargeset ))

  pattern(%w( _efficiency !number ), lambda {
    @property['efficiency', @scenarioIdx] = @val[1]
  })
  doc('efficiency', <<'EOT'
The efficiency of a resource can be used for two purposes. First you can use
it as a crude way to model a team. A team of 5 people should have an
efficiency of 5.0. Keep in mind that you cannot track the members of the team
individually if you use this feature. They always act as a group.

The other use is to model performance variations between your resources. Again, this is a fairly crude mechanism and should be used with care. A resource that isn't very good at some task might be pretty good at another. This can't be taken into account as the resource efficiency can only be set globally for all tasks.

All resources that do not contribute effort to the task, should have an
efficiency of 0.0. A typical example would be a conference room. It's necessary for a meeting, but it does not contribute any work.
EOT
     )
  example('Efficiency')
  pattern(%w( !flags ))
  doc('flags.resource', <<'EOT'
Attach a set of flags. The flags can be used in logical expressions to filter
properties from the reports.
EOT
     )

  pattern(%w( _booking !resourceBooking ))
  doc('booking.resource', <<'EOT'
The booking attribute can be used to report actually completed work.  A task
with bookings must be [[scheduling|scheduled]] in ''''ASAP'''' mode.  If the
scenario is not the [[trackingscenario|tracking scenario]] or derived from it,
the scheduler will not allocate resources prior to the current date or the
date specified with [[now]] when a task has at least one booking.

Bookings are only valid in the scenario they have been defined in. They will
in general not be passed to any other scenario. If you have defined a
[[trackingscenario|tracking scenario]], the bookings of this scenario will be
passed to all the derived scenarios of the tracking scenario.

The sloppy attribute can be used when you want to skip non-working time or
other allocations automatically. If it's not given, all bookings must only
cover working time for the resource.

The booking attributes is designed to capture the exact amount of completed
work. This attribute is not really intended to specify completed effort by
hand. Usually, booking statements are generated by [[export]] reports. The
[[sloppy.booking|sloppy]] and [[overtime.booking|overtime]] attributes are
only kludge for users who want to write them manually.
Bookings can be used to report already completed work by specifying the exact
time intervals a certain resource has worked on this task.

Bookings can be defined in the task or resource context. If you move tasks
around very often, put your bookings in the task context.
EOT
     )
  also(%w( scheduling booking.task ))
  example('Booking')

  pattern(%w( !fail ))

  pattern(%w( !leaveAllowances ))

  pattern(%w( !leaves ), lambda {
    @property['leaves', @scenarioIdx] += @val[0]
  })

  pattern(%w( !limits ), lambda {
    @property['limits', @scenarioIdx] = @val[0]
  })
  doc('limits.resource', <<'EOT'
Set per-interval usage limits for the resource.
EOT
     )
  example('Limits-1', '6')

  pattern(%w( _managers !resourceList ), lambda {
    @property['managers', @scenarioIdx] =
      @property['managers', @scenarioIdx] + @val[1]
  })
  doc('managers', <<'EOT'
Defines one or more resources to be the manager who is responsible for this
resource. Managers must be leaf resources. This attribute does not impact the
scheduling. It can only be used for documentation purposes.

You must only specify direct managers here. Do not list higher level managers
here. If necessary, use the [[purge]] attribute to clear
inherited managers. For most use cases, there should be only one manager. But
TaskJuggler is not limited to just one manager. Dotted reporting lines can be
captured as well as long as the managers are not reporting to each other.
EOT
     )
  also(%w( statussheet ))
  example('Manager')


  pattern(%w( _rate !number ), lambda {
    @property['rate', @scenarioIdx] = @val[1]
  })
  doc('rate.resource', <<'EOT'
The rate specifies the daily cost of the resource.
EOT
     )

  pattern(%w( !resourceShiftAssignments !shiftAssignments ), lambda {
    checkContainer('shifts')
    # Set same value again to set the 'provided' state for the attribute.
    begin
      @property['shifts', @scenarioIdx] = @shiftAssignments
    rescue AttributeOverwrite
      # Multiple shift assignments are a common idiom, so don't warn about
      # them.
    end
    @shiftAssignments = nil
  })
  level(:deprecated)
  also('shifts.resource')
  doc('shift.resource', <<'EOT'
This keyword has been deprecated. Please use [[shifts.resource|shifts
(resource)]] instead.
EOT
     )

  pattern(%w( !resourceShiftsAssignments !shiftAssignments ), lambda {
    checkContainer('shifts')
    # Set same value again to set the 'provided' state for the attribute.
    begin
      @property['shifts', @scenarioIdx] = @shiftAssignments
    rescue AttributeOverwrite
      # Multiple shift assignments are a common idiom, so don't warn about
      # them.
    end
    @shiftAssignments = nil
  })
  doc('shifts.resource', <<'EOT'
Limits the working time of a resource to a defined shift during the specified
interval. Multiple shifts can be defined, but shift intervals may not overlap.
In case a shift is defined for a certain interval, the shift working hours
replace the standard resource working hours for this interval.
EOT
      )

  pattern(%w( _vacation !vacationName !intervals ), lambda {
    @val[2].each do |interval|
      # We map the old 'vacation' attribute to public holidays.
      @property['leaves', @scenarioIdx] += [ Leave.new(:holiday, interval) ]
    end
  })
  doc('vacation.resource', <<'EOT'
Specify a vacation period for the resource. It can also be used to block out
the time before a resource joined or after it left. For employees changing
their work schedule from full-time to part-time, or vice versa, please refer
to the 'Shift' property.
EOT
     )

  pattern(%w( !warn ))

  pattern(%w( !workinghoursResource ))
  # Other attributes will be added automatically.
end

#rule_resourceShiftAssignmentsObject



5036
5037
5038
5039
5040
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5036

def rule_resourceShiftAssignments
  pattern(%w( _shift ), lambda {
    @shiftAssignments = @property['shifts', @scenarioIdx]
  })
end

#rule_resourceShiftsAssignmentsObject



5042
5043
5044
5045
5046
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5042

def rule_resourceShiftsAssignments
  pattern(%w( _shifts ), lambda {
    @shiftAssignments = @property['shifts', @scenarioIdx]
  })
end

#rule_rollupaccountObject



5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5048

def rule_rollupaccount
  pattern(%w( _rollupaccount !logicalExpression ), lambda {
    @property.set('rollupAccount', @val[1])
  })
  doc('rollupaccount', <<'EOT'
Do not show sub-accounts of accounts that match the specified
[[logicalexpression|logical expression]].
EOT
     )
end

#rule_rollupresourceObject



5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5059

def rule_rollupresource
  pattern(%w( _rollupresource !logicalExpression ), lambda {
    @property.set('rollupResource', @val[1])
  })
  doc('rollupresource', <<'EOT'
Do not show sub-resources of resources that match the specified
[[logicalexpression|logical expression]].
EOT
     )
  example('RollupResource')
end

#rule_rolluptaskObject



5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5071

def rule_rolluptask
  pattern(%w( _rolluptask !logicalExpression ), lambda {
    @property.set('rollupTask', @val[1])
  })
  doc('rolluptask', <<'EOT'
Do not show sub-tasks of tasks that match the specified
[[logicalexpression|logical expression]].
EOT
     )
end

#rule_scenarioObject



5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5083

def rule_scenario
  pattern(%w( !scenarioHeader !scenarioBody ), lambda {
    @property = @property.parent
  })
  doc('scenario', <<'EOT'
Defines a new project scenario. By default, the project has only one scenario
called ''''plan''''. To do plan vs. actual comparisons or to do a
what-if-analysis, you can define a set of scenarios. There can only be one
top-level scenario. Additional scenarios are either derived from this
top-level scenario or other scenarios.

Each nested scenario is a variation of the enclosing scenario. All scenarios
share the same set of properties (task, resources, etc.) but the attributes
that are listed as scenario specific may differ between the various
scenarios. A nested scenario uses all attributes from the enclosing scenario
unless the user has specified a different value for this attribute.

By default, the scheduler assigns resources to tasks beginning with the project
start date. If the scenario is switched to projection mode, no assignments
will be made prior to the current date or the date specified by [[now]]. In
this case, TaskJuggler assumes, that all assignments prior to the
current date have been provided by [[booking.task]] statements.
EOT
     )
end

#rule_scenarioAttributesObject



5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5109

def rule_scenarioAttributes
  optional
  repeatable

  pattern(%w( _active !yesNo), lambda {
    @property.set('active', @val[1])
  })
  doc('active', <<'EOT'
Enable the scenario to be scheduled or not. By default, all scenarios will be
scheduled. If a scenario is marked as inactive, it cannot be scheduled and will
be ignored in the reports.
EOT
     )
  pattern(%w( _disabled ), lambda {
    @property.set('active', false)
  })
  level(:deprecated)
  also('active')
  doc('disabled', <<'EOT'
This attribute is deprecated. Please use [active] instead.

Disable the scenario for scheduling. The default for the top-level
scenario is to be enabled.
EOT
     )
  example('Scenario')
  pattern(%w( _enabled ), lambda {
    @property.set('active', true)
  })
  level(:deprecated)
  also('active')
  doc('enabled', <<'EOT'
This attribute is deprecated. Please use [active] instead.

Enable the scenario for scheduling. This is the default for the top-level
scenario.
EOT
     )

  pattern(%w( _projection !projection ))
  level(:deprecated)
  also('booking.task')
  doc('projection', <<'EOT'
This keyword has been deprecated! Don't use it anymore!

Projection mode is now automatically enabled as soon as a scenario has
bookings.
EOT
     )

  pattern(%w( !scenario ))
end

#rule_scenarioBodyObject



5162
5163
5164
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5162

def rule_scenarioBody
  optionsRule('scenarioAttributes')
end

#rule_scenarioHeaderObject



5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5166

def rule_scenarioHeader

  pattern(%w( _scenario $ID $STRING ), lambda {
    # If this is the top-level scenario, we must delete the default scenario
    # first.
    @project.scenarios.each do |scenario|
      if scenario.get('projection')
        error('scenario_after_tracking',
              'Scenarios must be defined before a tracking scenario is set.')
      end
    end
    @project.scenarios.clearProperties if @property.nil?
    if @project.scenario(@val[1])
      error('scenario_exists',
            "Scenario #{@val[1]} has already been defined.",
            @sourceFileInfo[1])
    end
    @property = Scenario.new(@project, @val[1], @val[2], @property)
    @property.inheritAttributes

    if @project.scenarios.length > 1
      MessageHandlerInstance.instance.hideScenario = false
    end
  })
  arg(1, 'id', 'The ID of the scenario')
  arg(2, 'name', 'The name of the scenario')
end

#rule_scenarioIdObject



5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5194

def rule_scenarioId
  pattern(%w( $ID ), lambda {
    if (@scenarioIdx = @project.scenarioIdx(@val[0])).nil?
      error('unknown_scenario_id', "Unknown scenario: #{@val[0]}",
            @sourceFileInfo[0])
    end
    @scenarioIdx
  })
  arg(0, 'scenario', 'ID of a defined scenario')
end

#rule_scenarioIdColObject



5205
5206
5207
5208
5209
5210
5211
5212
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5205

def rule_scenarioIdCol
  pattern(%w( $ID_WITH_COLON ), lambda {
    if (@scenarioIdx = @project.scenarioIdx(@val[0])).nil?
      error('unknown_scenario_id', "Unknown scenario: #{@val[0]}",
            @sourceFileInfo[0])
    end
  })
end

#rule_scenarioIdListObject



5214
5215
5216
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5214

def rule_scenarioIdList
  listRule('moreScnarioIdList', '!scenarioIdx')
end

#rule_scenarioIdxObject



5218
5219
5220
5221
5222
5223
5224
5225
5226
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5218

def rule_scenarioIdx
  pattern(%w( $ID ), lambda {
    if (scenarioIdx = @project.scenarioIdx(@val[0])).nil?
      error('unknown_scenario_idx', "Unknown scenario #{@val[0]}",
            @sourceFileInfo[0])
    end
    scenarioIdx
  })
end

#rule_schedulingDirectionObject



5228
5229
5230
5231
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5228

def rule_schedulingDirection
  singlePattern('_alap')
  singlePattern('_asap')
end

#rule_schedulingModeObject



5233
5234
5235
5236
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5233

def rule_schedulingMode
  singlePattern('_planning')
  singlePattern('_projection')
end

#rule_shiftObject



5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5238

def rule_shift
  pattern(%w( !shiftHeader !shiftBody ), lambda {
    @property = @property.parent
  })
  doc('shift', <<'EOT'
A shift combines several workhours related settings in a reusable entity.
Besides the weekly working hours it can also hold information such as leaves
and a time zone. It lets you create a work time calendar that can be used to
limit the working time for resources or tasks.

Shifts have a global name space. All IDs must be unique within the shifts of
the project.
EOT
     )
  also(%w( shifts.task shifts.resource ))
end

#rule_shiftAssignmentObject



5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5255

def rule_shiftAssignment
  pattern(%w( !shiftId !intervalOptional ), lambda {
    # Make sure we have a ShiftAssignment for the property.
    unless @shiftAssignments
      @shiftAssignments = ShiftAssignments.new
      @shiftAssignments.project = @project
    end

    if @val[1].nil?
      interval = TimeInterval.new(@project['start'], @project['end'])
    else
      interval = @val[1]
    end
    if !@shiftAssignments.addAssignment(
       ShiftAssignment.new(@val[0].scenario(@scenarioIdx), interval))
      error('shift_assignment_overlap',
            'Shifts may not overlap each other.',
            @sourceFileInfo[0], @property)
    end
    @shiftAssignments.assignments.last
  })
end

#rule_shiftAssignmentsObject



5278
5279
5280
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5278

def rule_shiftAssignments
  listRule('moreShiftAssignments', '!shiftAssignment')
end

#rule_shiftAttributesObject



5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5282

def rule_shiftAttributes
  optional
  repeatable

  pattern(%w( !shift ))
  pattern(%w( !shiftScenarioAttributes ))
  pattern(%w( !scenarioIdCol !shiftScenarioAttributes ), lambda {
    @scenarioIdx = 0
  })
end

#rule_shiftBodyObject



5293
5294
5295
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5293

def rule_shiftBody
  optionsRule('shiftAttributes')
end

#rule_shiftHeaderObject



5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5297

def rule_shiftHeader
  pattern(%w( _shift !optionalID $STRING ), lambda {
    if @val[1] && @project.shift(@val[1])
      error('shift_exists', "Shift #{@val[1]} has already been defined.",
            @sourceFileInfo[1])
    end
    @property = Shift.new(@project, @val[1], @val[2], @property)
    @property.sourceFileInfo = @sourceFileInfo[0]
    @property.inheritAttributes
    @scenarioIdx = 0
  })
  arg(2, 'name', 'The name of the shift')
end

#rule_shiftIdObject



5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5311

def rule_shiftId
  pattern(%w( $ID ), lambda {
    if (shift = @project.shift(@val[0])).nil?
      error('shift_id_expected', "#{@val[0]} is not a defined shift.",
            @sourceFileInfo[0])
    end
    shift
  })
  arg(0, 'shift', 'The ID of a defined shift')
end

#rule_shiftScenarioAttributesObject



5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5322

def rule_shiftScenarioAttributes
  pattern(%w( !leaves ), lambda {
    @property['leaves', @scenarioIdx] += @val[0]
  })

  pattern(%w( _replace ), lambda {
    @property['replace', @scenarioIdx] = true
  })
  doc('replace', <<'EOT'
This replace mode is only effective for shifts that are assigned to resources
directly. When replace mode is activated the leave definitions of the shift
will replace all the leave definitions of the resource for the given period.

The mode is not effective for shifts that are assigned to tasks or allocations.
EOT
     )

  pattern(%w( _timezone !validTimeZone ), lambda {
    @property['timezone', @scenarioIdx] = @val[1]
  })
  doc('timezone.shift', <<'EOT'
Sets the time zone of the shift. The working hours of the shift are assumed to
be within the specified time zone. The time zone does not effect the vaction
interval. The latter is assumed to be within the project time zone.

TaskJuggler stores all dates internally as UTC. Since all events must align
with the [[timingresolution|timing resolution]] for time zones you may have to
change the timing resolution appropriately. The time zone difference compared
to UTC must be a multiple of the used timing resolution.
EOT
      )
  arg(1, 'zone', <<'EOT'
Time zone to use. E. g. 'Europe/Berlin' or 'America/Denver'. Don't use the 3
letter acronyms. See
[http://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones Wikipedia] for
possible values.
EOT
     )

  pattern(%w( _vacation !vacationName !intervalsOptional ), lambda {
    @val[2].each do |interval|
      # We map the old 'vacation' attribute to public holidays.
      @property['leaves', @scenarioIdx] += [ Leave.new(:holiday, interval) ]
    end
  })
  doc('vacation.shift', <<'EOT'
Specify a vacation period associated with this shift.
EOT
     )

  pattern(%w( !workinghoursShift ))
end

#rule_sortAccountsObject



5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5497

def rule_sortAccounts
  pattern(%w( !sortAccountsKeyword !sortCriteria ), lambda {
    @property.set('sortAccounts', @val[1])
  })
  doc('sortaccounts', <<'EOT'
Determines how the accounts are sorted in the report. Multiple criteria can be
specified as a comma separated list. If one criteria is not sufficient to sort
a group of accounts, the next criteria will be used to sort the accounts in
this group.
EOT
     )
end

#rule_sortAccountsKeywordObject



5491
5492
5493
5494
5495
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5491

def rule_sortAccountsKeyword
  pattern(%w( _sortaccounts ), lambda {
    @sortProperty = :account
  })
end

#rule_sortCriteriaObject



5375
5376
5377
5378
5379
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5375

def rule_sortCriteria
  pattern([ "!sortCriterium", "!moreSortCriteria" ], lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_sortCriteriumObject



5381
5382
5383
5384
5385
5386
5387
5388
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5381

def rule_sortCriterium
  pattern(%w( !sortTree ), lambda {
    @val[0]
  })
  pattern(%w( !sortNonTree ), lambda {
    @val[0]
  })
end

#rule_sortJournalEntriesObject



5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5466

def rule_sortJournalEntries
  pattern(%w( _sortjournalentries !journalSortCriteria ), lambda {
    @property.set('sortJournalEntries', @val[1])
  })
  doc('sortjournalentries', <<'EOT'
Determines how the entries in a journal are sorted. Multiple criteria can be
specified as a comma separated list. If one criteria is not sufficient to sort
a group of journal entries, the next criteria will be used to sort the entries
in this group.

The following values are supported:
* ''''date.down'''': Sort descending order by the date of the journal entry
* ''''date.up'''': Sort ascending order by the date of the journal entry
* ''''alert.down'''': Sort in descending order by the alert level of the
journal entry
* ''''alert.up'''': Sort in ascending order by the alert level of the
journal entry
 ''''property.down'''': Sort in descending order by the task or resource
the journal entry is associated with
* ''''property.up'''': Sort in ascending order by the task or resource the
journal entry is associated with
EOT
      )
end

#rule_sortNonTreeObject



5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5390

def rule_sortNonTree
  pattern(%w( $ABSOLUTE_ID ), lambda {
    args = @val[0].split('.')
    case args.length
    when 2
      # <attribute>.<up|down>
      # We default to the top-level scenario.
      if args[1] != 'up' && args[1]!= 'down'
        error('sort_direction', "Sorting direction must be 'up' or 'down'",
              @sourceFileInfo[0])
      end

      scenario = -1
      direction = args[1] == 'up'
      attribute = args[0]
    when 3
      # <scenario>.<attribute>.<up|down>
      if (scenario = @project.scenarioIdx(args[0])).nil?
        error('sort_unknown_scen',
              "Unknown scenario #{args[0]} in sorting criterium",
              @sourceFileInfo[0])
      end
      attribute = args[1]
      if args[2] != 'up' && args[2] != 'down'
        error('sort_direction', "Sorting direction must be 'up' or 'down'",
              @sourceFileInfo[0])
      end
      direction = args[2] == 'up'
    else
      error('sorting_crit_exptd1',
            "Sorting criterium expected (e.g. tree, start.up or " +
            "plan.end.down).", @sourceFileInfo[0])
    end
    if attribute == 'bsi'
      error('sorting_bsi',
            "Sorting by bsi is not supported. Please use 'tree' " +
            '(without appended .up or .down) instead.',
            @sourceFileInfo[0])
    end
    case @sortProperty
    when :account
      ps = @project.accounts
    when :resource
      ps = @project.resources
    when :task
      ps = @project.tasks
    end
    unless ps.knownAttribute?(attribute) ||
      TableReport::calculated?(attribute)
      error('sorting_unknown_attr',
            "Sorting criterium '#{attribute} is not a known attribute.")
    end
    if scenario > 0 && !(ps.scenarioSpecific?(attribute) ||
                         TableReport.scenarioSpecific?(attribute))
      error('sorting_attr_scen_spec',
            "Sorting criterium '#{attribute}' is not scenario specific " +
            "but a scenario has been specified.")
    elsif scenario == -1 && (ps.scenarioSpecific?(attribute) ||
                             TableReport.scenarioSpecific?(attribute))
      # If no scenario was specified but the attribute is scenario specific,
      # we default to the top-level scenario.
      scenario = 0
    end
    [ attribute, direction, scenario ]
  })
  arg(0, 'criteria', <<'EOT'
The sorting criteria must consist of a property attribute ID. See [[columnid]]
for a complete list of available attributes. The ID must be suffixed by '.up'
or '.down' to determine the sorting direction. Optionally the ID may be
prefixed with a scenario ID and a dot to determine the scenario that should be
used for sorting. In case no scenario was specified, the top-level scenario is
used. Example values are 'plan.start.up' or 'priority.down'.
EOT
       )
end

#rule_sortResourcesObject



5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5516

def rule_sortResources
  pattern(%w( !sortResourcesKeyword !sortCriteria ), lambda {
    @property.set('sortResources', @val[1])
  })
  doc('sortresources', <<'EOT'
Determines how the resources are sorted in the report. Multiple criteria can be
specified as a comma separated list. If one criteria is not sufficient to sort
a group of resources, the next criteria will be used to sort the resources in
this group.
EOT
     )
end

#rule_sortResourcesKeywordObject



5510
5511
5512
5513
5514
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5510

def rule_sortResourcesKeyword
  pattern(%w( _sortresources ), lambda {
    @sortProperty = :resource
  })
end

#rule_sortTasksObject



5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5535

def rule_sortTasks
  pattern(%w( !sortTasksKeyword !sortCriteria ), lambda {
    @property.set('sortTasks', @val[1])
  })
  doc('sorttasks', <<'EOT'
Determines how the tasks are sorted in the report. Multiple criteria can be
specified as comma separated list. If one criteria is not sufficient to sort a
group of tasks, the next criteria will be used to sort the tasks within
this group.
EOT
     )
end

#rule_sortTasksKeywordObject



5529
5530
5531
5532
5533
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5529

def rule_sortTasksKeyword
  pattern(%w( _sorttasks ), lambda {
    @sortProperty = :task
  })
end

#rule_sortTreeObject



5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5548

def rule_sortTree
  pattern(%w( $ID ), lambda {
    if @val[0] != 'tree'
      error('sorting_crit_exptd2',
            "Sorting criterium expected (e.g. tree, start.up or " +
            "plan.end.down).", @sourceFileInfo[0])
    end
    [ 'tree', true, -1 ]
  })
  arg(0, 'tree',
      'Use \'tree\' as first criteria to keep the breakdown structure.')
end

#rule_ssReportAttributesObject



5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5587

def rule_ssReportAttributes
  optional
  repeatable

  pattern(%w( !hideresource ))
  pattern(%w( !hidetask ))
  pattern(%w( !reportEnd ))
  pattern(%w( !reportPeriod ))
  pattern(%w( !reportStart ))
  pattern(%w( !sortResources ))
  pattern(%w( !sortTasks ))
end

#rule_ssReportBodyObject



5600
5601
5602
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5600

def rule_ssReportBody
  optionsRule('ssReportAttributes')
end

#rule_ssReportHeaderObject



5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5560

def rule_ssReportHeader
  pattern(%w( _statussheetreport !optionalID $STRING ), lambda {
    newReport(@val[1], @val[2], :statusSheet, @sourceFileInfo[0]) do
      @property.set('formats', [ :tjp ])

      unless (@project['trackingScenarioIdx'])
        error('ss_no_tracking_scenario',
              'You must have a tracking scenario defined to use status sheets.')
      end
      # Show all tasks, sorted by id-up.
      @property.set('hideTask', LogicalExpression.new(LogicalOperation.new(0)))
      @property.set('sortTasks', [ [ 'id', true, -1 ] ])
      # Show all resources, sorted by seqno-up.
      @property.set('hideResource',
                    LogicalExpression.new(LogicalOperation.new(0)))
      @property.set('sortResources', [ [ 'seqno', true, -1 ] ])
      @property.set('loadUnit', :hours)
      @property.set('definitions', [])
    end
  })
  arg(2, 'file name', <<'EOT'
The name of the status sheet report file to generate. It must end with a .tji
extension, or use . to use the standard output channel.
EOT
     )
end

#rule_ssStatusObject



5643
5644
5645
5646
5647
5648
5649
5650
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5643

def rule_ssStatus
  pattern(%w( !ssStatusHeader !ssStatusBody ))
  doc('status.statussheet', <<'EOT'
The status attribute can be used to describe the current status of the task or
resource. The content of the status messages is added to the project journal.
EOT
     )
end

#rule_ssStatusAttributesObject



5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5604

def rule_ssStatusAttributes
  optional
  repeatable

  pattern(%w( !author ))
  pattern(%w( !details ))

  pattern(%w( _flags !flagList ), lambda {
    @val[1].each do |flag|
      next if @journalEntry.flags.include?(flag)

      @journalEntry.flags << flag
    end
  })
  doc('flags.statussheet', <<'EOT'
Status sheet entries can have flags attached to them. These can be used to
include only entries in a report that have a certain flag.
EOT
     )

  pattern(%w( !summary ))
end

#rule_ssStatusBodyObject



5627
5628
5629
5630
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5627

def rule_ssStatusBody
  optional
  pattern(%w( _{ !ssStatusAttributes _} ))
end

#rule_ssStatusHeaderObject



5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5632

def rule_ssStatusHeader
  pattern(%w( _status !alertLevel $STRING ), lambda {
    @journalEntry = JournalEntry.new(@project['journal'], @sheetEnd,
                                     @val[2], @property,
                                     @sourceFileInfo[0])
    @journalEntry.alertLevel = @val[1]
    @journalEntry.author = @sheetAuthor
    @journalEntry.moderators << @sheetModerator
  })
end

#rule_statusSheetObject



5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5652

def rule_statusSheet
  pattern(%w( !statusSheetHeader !statusSheetBody ), lambda {
    [ @sheetAuthor, @sheetStart, @sheetEnd ]
  })
  doc('statussheet', <<'EOT'
A status sheet can be used to capture the status of various tasks outside of
the regular task tree definition. It is intended for use by managers that
don't directly work with the full project plan, but need to report the current
status of each task or task-tree that they are responsible for.
EOT
     )
  example('StatusSheet')
end

#rule_statusSheetAttributesObject



5666
5667
5668
5669
5670
5671
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5666

def rule_statusSheetAttributes
  optional
  repeatable

  pattern(%w( !statusSheetTask ))
end

#rule_statusSheetBodyObject



5673
5674
5675
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5673

def rule_statusSheetBody
  optionsRule('statusSheetAttributes')
end

#rule_statusSheetFileObject



5677
5678
5679
5680
5681
5682
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5677

def rule_statusSheetFile
  pattern(%w( !statusSheet . ), lambda {
    @val[0]
  })
  lastSyntaxToken(1)
end

#rule_statusSheetHeaderObject



5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5685

def rule_statusSheetHeader
  pattern(%w( _statussheet !resourceId !valIntervalOrDate ), lambda {
    unless @project['trackingScenarioIdx']
      error('ss_no_tracking_scenario',
            'No trackingscenario defined.')
    end
    @sheetAuthor = @val[1]
    @sheetModerator = @val[1]
    @sheetStart = @val[2].start
    @sheetEnd = @val[2].end
    # Make sure that we don't have any status sheet entries from the same
    # author for the same report period. There may have been a previous
    # submission of the same report and this is an update to it. All old
    # entries must be removed before we process the sheet.
    @project['journal'].delete_if do |e|
      # Journal entries from status sheets have the sheet end date as entry
      # date.
      e.moderators.include?(@sheetModerator) && e.date == @sheetEnd
    end
  })
  arg(1, 'reporter', <<'EOT'
The ID of a defined resource. This identifies the status reporter. Unless the
status entries provide a different author, the sheet author will be used as
status entry author.
EOT
     )
end

#rule_statusSheetReportObject



5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5713

def rule_statusSheetReport
  pattern(%w( !ssReportHeader !ssReportBody ), lambda {
    @property = nil
  })
  doc('statussheetreport', <<'EOT'
A status sheet report is a template for a status sheet. It collects all the
status information of the top-level task that a resource is responsible for.
This report is typically used by managers or team leads to review the time
sheet status information and destill it down to a summary that can be
forwarded to the next person in the reporting chain. The report will be for
the specified [trackingscenario].
EOT
     )
end

#rule_statusSheetTaskObject



5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5728

def rule_statusSheetTask
  pattern(%w( !statusSheetTaskHeader !statusSheetTaskBody), lambda {
    @property = @propertyStack.pop
  })
  doc('task.statussheet', <<'EOT'
Opens the task with the specified ID to add a status report. Child tasks can be
opened inside this context by specifying their relative ID to this parent.
EOT
     )
end

#rule_statusSheetTaskAttributesObject



5739
5740
5741
5742
5743
5744
5745
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5739

def rule_statusSheetTaskAttributes
  optional
  repeatable
  pattern(%w( !ssStatus ))
  pattern(%w( !statusSheetTask ), lambda {
  })
end

#rule_statusSheetTaskBodyObject



5747
5748
5749
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5747

def rule_statusSheetTaskBody
  optionsRule('statusSheetTaskAttributes')
end

#rule_statusSheetTaskHeaderObject



5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5751

def rule_statusSheetTaskHeader
  pattern(%w( _task !taskId ), lambda {
    if @property
      @propertyStack.push(@property)
    else
      @propertyStack = []
    end
    @property = @val[1]
  })
end

#rule_subNodeIdObject



5762
5763
5764
5765
5766
5767
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5762

def rule_subNodeId
  optional
  pattern(%w( _: !idOrAbsoluteId ), lambda {
    @val[1]
  })
end

#rule_summaryObject



5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5769

def rule_summary
  pattern(%w( _summary $STRING ), lambda {
    return if @val[1].empty?

    if @val[1].length > 480
      error('ts_summary_too_long',
            "The summary text must be 480 characters long or shorter. " +
            "This text has #{@val[1].length} characters.",
            @sourceFileInfo[1])
    end
    if @val[1] == "A summary text\n"
        error('ts_default_summary',
              "'A summary text' is not a valid summary",
              @sourceFileInfo[1])
    end
    rtTokenSetIntro =
      [ :LINEBREAK, :SPACE, :WORD, :BOLD, :ITALIC, :CODE, :BOLDITALIC,
        :HREF, :HREFEND ]
    @journalEntry.summary = newRichText(@val[1], @sourceFileInfo[1],
                                        rtTokenSetIntro)
  })
  doc('summary', <<'EOT'
This is the introductory part of the journal or status entry. It should
only summarize the full entry but should contain more details than the
headline. The text including formatting characters must be 240 characters long
or less.
EOT
     )
  arg(1, 'text', <<'EOT'
The text will be interpreted as [[Rich_Text_Attributes|Rich Text]]. Only a
small subset of the markup is supported for this attribute. You can use word
formatting, hyperlinks and paragraphs.
EOT
     )
end

#rule_supplementObject



5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5805

def rule_supplement
  pattern(%w( !supplementAccount !accountBody ), lambda {
    @property = @idStack.pop
  })
  pattern(%w( !supplementReport !reportBody ), lambda {
    @property = @idStack.pop
  })
  pattern(%w( !supplementResource !resourceBody ), lambda {
    @property = @idStack.pop
  })
  pattern(%w( !supplementTask !taskBody ), lambda {
    @property = @idStack.pop
  })
end

#rule_supplementAccountObject



5820
5821
5822
5823
5824
5825
5826
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5820

def rule_supplementAccount
  pattern(%w( _account !accountId ), lambda {
    @idStack.push(@property)
    @property = @val[1]
  })
  arg(1, 'account ID', 'The ID of an already defined account.')
end

#rule_supplementReportObject



5828
5829
5830
5831
5832
5833
5834
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5828

def rule_supplementReport
  pattern(%w( _report !reportId ), lambda {
    @idStack.push(@property)
    @property = @val[1]
  })
  arg(1, 'report ID', 'The absolute ID of an already defined report.')
end

#rule_supplementResourceObject



5836
5837
5838
5839
5840
5841
5842
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5836

def rule_supplementResource
  pattern(%w( _resource !resourceId ), lambda {
    @idStack.push(@property)
    @property = @val[1]
  })
  arg(1, 'resource ID', 'The ID of an already defined resource.')
end

#rule_supplementTaskObject



5844
5845
5846
5847
5848
5849
5850
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5844

def rule_supplementTask
  pattern(%w( _task !taskId ), lambda {
    @idStack.push(@property)
    @property = @val[1]
  })
  arg(1, 'task ID', 'The absolute ID of an already defined task.')
end

#rule_tagfileObject



5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5852

def rule_tagfile
  pattern(%w( !tagfileHeader !tagfileBody ), lambda {
    @property = nil
  })
  doc('tagfile', <<'EOT'
The tagfile report generates a file that maps properties to source file
locations. This can be used by editors to quickly jump to a certain task or
resource definition. Currently only the ctags format is supported that is used
by editors like [http://www.vim.org|vim].
EOT
     )
end

#rule_tagfileAttributesObject



5886
5887
5888
5889
5890
5891
5892
5893
5894
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5886

def rule_tagfileAttributes
  optional
  repeatable

  pattern(%w( !hideresource ))
  pattern(%w( !hidetask ))
  pattern(%w( !rollupresource ))
  pattern(%w( !rolluptask ))
end

#rule_tagfileBodyObject



5896
5897
5898
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5896

def rule_tagfileBody
  optionsRule('tagfileAttributes')
end

#rule_tagfileHeaderObject



5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5865

def rule_tagfileHeader
  pattern(%w( _tagfile !optionalID $STRING ), lambda {
    newReport(@val[1], @val[2], :tagfile, @sourceFileInfo[0]) do
      @property.set('formats', [ :ctags ])

      # Include all tasks.
      @property.set('hideTask', LogicalExpression.new(LogicalOperation.new(0)))
      @property.set('sortTasks', [ [ 'seqno', true, -1 ] ])
      # Include all resources.
      @property.set('hideResource',
                    LogicalExpression.new(LogicalOperation.new(0)))
      @property.set('sortResources', [ [ 'seqno', true, -1 ] ])
    end
  })
  arg(2, 'file name', <<'EOT'
The name of the tagfile to generate. Use ''''tags'''' if you want vim and
other tools to find it automatically.
EOT
     )
end

#rule_taskObject



5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5901

def rule_task
  pattern(%w( !taskHeader !taskBody ), lambda {
    @property = @property.parent
  })
  doc('task', <<'EOT'
Tasks are the central elements of a project plan. Use a task to specify the
various steps and phases of the project. Depending on the attributes of that
task, a task can be a container task, a milestone or a regular leaf task. The
latter may have resources assigned. By specifying dependencies the user can
force a certain sequence of tasks.

Tasks have a local name space. All IDs must be unique within the tasks
that belong to the same enclosing task.
EOT
     )
end

#rule_taskAttributesObject



5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5918

def rule_taskAttributes
  repeatable
  optional

  pattern(%w( _adopt !taskList ), lambda {
    @val[1].each do |task|
      @property.adopt(task)
    end
  })
  level(:experimental)
  doc('adopt.task', <<'EOT'
Add a previously defined task and its sub-tasks to this task. This can be used
to create virtual projects that contain task (sub-)trees that are originally
defined in another task context. Adopted tasks don't inherit anything from
their step parents. However, the adopting task is scheduled to fit all adopted
sub-tasks.

A top-level task and all its sub-tasks must never contain the same task more
than once. All reports must use appropriate filters by setting [[taskroot]],
[[hidetask]] or [[rolluptask]] to ensure that no tasks are contained more than
once in the report.
EOT
     )

  pattern(%w( !journalEntry ))

  pattern(%w( _note $STRING ), lambda {
    @property.set('note', newRichText(@val[1], @sourceFileInfo[1]))
  })
  doc('note.task', <<'EOT'
Attach a note to the task. This is usually a more detailed specification of
what the task is about.
EOT
     )

  pattern(%w( !purge ))

  pattern(%w( _supplement !supplementTask !taskBody ), lambda {
    @property = @idStack.pop
  })
  doc('supplement.task', <<'EOT'
The supplement keyword provides a mechanism to add more attributes to already
defined tasks. The additional attributes must obey the same rules as in
regular task definitions and must be enclosed by curly braces.

This construct is primarily meant for situations where the information about a
task is split over several files. E. g. the vacation dates for the
resources may be in a separate file that was generated by some other tool.
EOT
     )
  example('Supplement', 'task')

  pattern(%w( !task ))
  pattern(%w( !taskScenarioAttributes ))
  pattern(%w( !scenarioIdCol !taskScenarioAttributes ), lambda {
    @scenarioIdx = 0
  })
  # Other attributes will be added automatically.
end

#rule_taskBodyObject



5978
5979
5980
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5978

def rule_taskBody
  optionsRule('taskAttributes')
end

#rule_taskBookingObject



5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5982

def rule_taskBooking
  pattern(%w( !taskBookingHeader !bookingBody ), lambda {
    unless @project.scenario(@scenarioIdx).get('ownbookings')
      error('no_own_task_booking',
            "The scenario #{@project.scenario(@scenarioIdx).fullId} " +
            'inherits its bookings from the tracking ' +
            'scenario. You cannot specificy additional bookings for it.')
    end
    @val[0].task.addBooking(@scenarioIdx, @val[0])
  })
end

#rule_taskBookingHeaderObject



5994
5995
5996
5997
5998
5999
6000
6001
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 5994

def rule_taskBookingHeader
  pattern(%w( !resourceId !valIntervals ), lambda {
    checkBooking(@property, @val[0])
    @booking = Booking.new(@val[0], @property, @val[1])
    @booking.sourceFileInfo = @sourceFileInfo[0]
    @booking
  })
end

#rule_taskDepObject



6003
6004
6005
6006
6007
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6003

def rule_taskDep
  pattern(%w( !taskDepHeader !taskDepBody ), lambda {
    @val[0]
  })
end

#rule_taskDepAttributesObject



6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6009

def rule_taskDepAttributes
  optional
  repeatable

  pattern(%w( _gapduration !intervalDuration ), lambda {
    @taskDependency.gapDuration = @val[1]
  })
  doc('gapduration', <<'EOT'
Specifies the minimum required gap between the start or end of a preceding
task and the start of this task, or the start or end of a following task and
the end of this task. This is calendar time, not working time. 7d means one
week.
EOT
     )

  pattern(%w( _gaplength !nonZeroWorkingDuration ), lambda {
    @taskDependency.gapLength = @val[1]
  })
  doc('gaplength', <<'EOT'
Specifies the minimum required gap between the start or end of a preceding
task and the start of this task, or the start or end of a following task and
the end of this task. This is working time, not calendar time. 7d means 7
working days, not one week. Whether a day is considered a working day or not
depends on the defined working hours and global leaves.
EOT
     )

  pattern(%w( _onend ), lambda {
    @taskDependency.onEnd = true
  })
  doc('onend', <<'EOT'
The target of the dependency is the end of the task.
EOT
     )

  pattern(%w( _onstart ), lambda {
    @taskDependency.onEnd = false
  })
  doc('onstart', <<'EOT'
The target of the dependency is the start of the task.
EOT
     )
end

#rule_taskDepBodyObject



6053
6054
6055
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6053

def rule_taskDepBody
  optionsRule('taskDepAttributes')
end

#rule_taskDepHeaderObject



6057
6058
6059
6060
6061
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6057

def rule_taskDepHeader
  pattern(%w( !taskDepId ), lambda {
    @taskDependency = TaskDependency.new(@val[0], true)
  })
end

#rule_taskDepIdObject



6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6063

def rule_taskDepId
  singlePattern('$ABSOLUTE_ID')
  arg(0, 'ABSOLUTE ID', <<'EOT'
A reference using the full qualified ID of a task. The IDs of all enclosing
parent tasks must be prepended to the task ID and separated with a dot, e.g.
''''proj.plan.doc''''.
EOT
       )

  singlePattern('$ID')
  arg(0, 'ID', 'Just the ID of the task without any parent IDs.')

  pattern(%w( !relativeId ), lambda {
    task = @property
    id = @val[0]
    while task && id[0] == ?!
      id = id.slice(1, id.length)
      task = task.parent
    end
    error('too_many_bangs',
          "Too many '!' for relative task in this context.",
          @sourceFileInfo[0], @property) if id[0] == ?!
    if task
      task.fullId + '.' + id
    else
      id
    end
  })
  arg(0, 'RELATIVE ID', <<'EOT'
A relative task ID always starts with one or more exclamation marks and is
followed by a task ID. Each exclamation mark lifts the scope where the ID is
looked for to the enclosing task. The ID may contain some of the parent IDs
separated by dots, e. g. ''''!!plan.doc''''.
EOT
       )
end

#rule_taskDepListObject



6100
6101
6102
6103
6104
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6100

def rule_taskDepList
  pattern(%w( !taskDep !moreDepTasks ), lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_taskHeaderObject



6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6106

def rule_taskHeader
  pattern(%w( _task !optionalID $STRING ), lambda {
    if @property.nil? && !@taskprefix.empty?
      @property = @project.task(@taskprefix)
    end
    if @val[1]
      id = (@property ? @property.fullId + '.' : '') + @val[1]
      if @project.task(id)
        error('task_exists', "Task #{id} has already been defined.",
              @sourceFileInfo[0])
      end
    end
    @property = Task.new(@project, @val[1], @val[2], @property)
    @property['projectid', 0] = @projectId
    @property.sourceFileInfo = @sourceFileInfo[0]
    @property.inheritAttributes
    @scenarioIdx = 0
  })
  arg(2, 'name', 'The name of the task')
end

#rule_taskIdObject



6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6127

def rule_taskId
  pattern(%w( !taskIdUnverifd ), lambda {
    id = @val[0]
    if @property && @property.is_a?(Task)
      # In case we have a nested supplement, we need to prepend the parent ID.
      id = @property.fullId + '.' + id
    else
      id = @taskprefix + '.' + id unless @taskprefix.empty?
    end
    if (task = @project.task(id)).nil?
      error('unknown_task', "Unknown task #{id}", @sourceFileInfo[0])
    end
    task
  })
end

#rule_taskIdUnverifdObject



6143
6144
6145
6146
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6143

def rule_taskIdUnverifd
  singlePattern('$ABSOLUTE_ID')
  singlePattern('$ID')
end

#rule_taskListObject



6148
6149
6150
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6148

def rule_taskList
  listRule('moreTasks', '!absoluteTaskId')
end

#rule_taskPeriodObject



6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6152

def rule_taskPeriod
  pattern(%w( _period !valInterval), lambda {
    @property['start', @scenarioIdx] = @val[1].start
    @property['end', @scenarioIdx] = @val[1].end
  })
  doc('period.task', <<'EOT'
This property is a shortcut for setting the start and end property at the same
time. In contrast to using these, it does not change the scheduling direction.
EOT
     )
end

#rule_taskPredObject



6164
6165
6166
6167
6168
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6164

def rule_taskPred
  pattern(%w( !taskPredHeader !taskDepBody ), lambda {
    @val[0]
  })
end

#rule_taskPredHeaderObject



6170
6171
6172
6173
6174
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6170

def rule_taskPredHeader
  pattern(%w( !taskDepId ), lambda {
    @taskDependency = TaskDependency.new(@val[0], false)
  })
end

#rule_taskPredListObject



6176
6177
6178
6179
6180
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6176

def rule_taskPredList
  pattern(%w( !taskPred !morePredTasks ), lambda {
    [ @val[0] ] + (@val[1].nil? ? [] : @val[1])
  })
end

#rule_taskReportObject



6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6182

def rule_taskReport
  pattern(%w( !taskReportHeader !reportBody ), lambda {
    @property = @property.parent
  })
  doc('taskreport', <<'EOT'
The report lists tasks and their respective values in a table. To reduce the
list of included tasks, you can use the [[hidetask]], [[rolluptask]] or
[[taskroot]] attributes. The order of the tasks can be controlled with
[[sorttasks]]. If the first sorting criteria is tree sorting, the parent tasks
will always be included to form the tree. Tree sorting is the default. You
need to change it if you do not want certain parent tasks to be included in
the report.

By default, all the resources that are allocated to each task are hidden, but
they can be listed as well. Use the [[hideresource]] attribute to select which
resources should be included.
EOT
     )
  example('HtmlTaskReport')
end

#rule_taskReportHeaderObject



6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6203

def rule_taskReportHeader
  pattern(%w( _taskreport !optionalID !reportName ), lambda {
    newReport(@val[1], @val[2], :taskreport, @sourceFileInfo[0]) do
      unless @property.modified?('columns')
        # Set the default columns for this report.
        %w( bsi name start end effort chart ).each do |col|
          @property.get('columns') <<
          TableColumnDefinition.new(col, columnTitle(col))
        end
      end
      # Show all tasks, sorted by tree, start-up, seqno-up.
      unless @property.modified?('hideTask')
        @property.set('hideTask',
                      LogicalExpression.new(LogicalOperation.new(0)))
      end
      unless @property.modified?('sortTasks')
        @property.set('sortTasks',
                      [ [ 'tree', true, -1 ],
                        [ 'start', true, 0 ],
                        [ 'seqno', true, -1 ] ])
      end
      # Show no resources, but set sorting to id-up.
      unless @property.modified?('hideResource')
        @property.set('hideResource',
                      LogicalExpression.new(LogicalOperation.new(1)))
      end
      unless @property.modified?('sortResources')
        @property.set('sortResources', [ [ 'id', true, -1 ] ])
      end
    end
  })
end

#rule_taskScenarioAttributesObject



6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6236

def rule_taskScenarioAttributes

  pattern(%w( _account $ID ))
  level(:removed)
  also('chargeset')
  doc('account.task', '')

  pattern(%w( !allocate ))

  pattern(%w( _booking !taskBooking ))
  doc('booking.task', <<'EOT'
The booking attribute can be used to report actually completed work.  A task
with bookings must be [[scheduling|scheduled]] in ''''ASAP'''' mode.  If the
scenario is not the [[trackingscenario|tracking scenario]] or derived from it,
the scheduler will not allocate resources prior to the current date or the
date specified with [[now]] when a task has at least one booking.

Bookings are only valid in the scenario they have been defined in. They will
in general not be passed to any other scenario. If you have defined a
[[trackingscenario|tracking scenario]], the bookings of this scenario will be
passed to all the derived scenarios of the tracking scenario.

The sloppy attribute can be used when you want to skip non-working time or
other allocations automatically. If it's not given, all bookings must only
cover working time for the resource.

The booking attributes is designed to capture the exact amount of completed
work. This attribute is not really intended to specify completed effort by
hand. Usually, booking statements are generated by [[export]] reports. The
[[sloppy.booking|sloppy]] and [[overtime.booking|overtime]] attributes are
only kludge for users who want to write them manually.
Bookings can be used to report already completed work by specifying the exact
time intervals a certain resource has worked on this task.

Bookings can be defined in the task or resource context. If you move tasks
around very often, put your bookings in the task context.
EOT
     )
  also(%w( booking.resource ))
  example('Booking')

  pattern(%w( _charge !number !chargeMode ), lambda {
    checkContainer('charge')

    if @property['chargeset', @scenarioIdx].empty?
      error('task_without_chargeset',
            'The task does not have a chargeset defined.',
            @sourceFileInfo[0], @property)
    end
    case @val[2]
    when 'onstart'
      mode = :onStart
      amount = @val[1]
    when 'onend'
      mode = :onEnd
      amount = @val[1]
    when 'perhour'
      mode = :perDiem
      amount = @val[1] * 24
    when 'perday'
      mode = :perDiem
      amount = @val[1]
    when 'perweek'
      mode = :perDiem
      amount = @val[1] / 7.0
    end
    @property['charge', @scenarioIdx] +=
      [ Charge.new(amount, mode, @property, @scenarioIdx) ]
  })
  doc('charge', <<'EOT'
Specify a one-time or per-period charge to a certain account. The charge can
occur at the start of the task, at the end of it, or continuously over the
duration of the task. The accounts to be charged are determined by the
[[chargeset]] setting of the task.
EOT
     )
  arg(1, 'amount', 'The amount to charge')

  pattern(%w( !chargeset ))

  pattern(%w( _complete !number), lambda {
    if @val[1] < 0.0 || @val[1] > 100.0
      error('task_complete', "Complete value must be between 0 and 100",
            @sourceFileInfo[1], @property)
    end
    @property['complete', @scenarioIdx] = @val[1]
  })
  doc('complete', <<'EOT'
Specifies what percentage of the task is already completed. This can be useful
for simple progress tracking like in a TODO list. The provided completion
degree is used for the ''''complete'''' and ''''gauge'''' columns in reports.
Reports with calendar elements may show the completed part of the task in a
different color.

The completion percentage has no impact on the scheduler. It's meant for
documentation purposes only.
EOT
      )
  example('Complete', '1')

  arg(1, 'percent', 'The percent value. It must be between 0 and 100.')

  pattern(%w( _depends !taskDepList ), lambda {
    checkContainer('depends')
    @property['depends', @scenarioIdx] += @val[1]
    begin
      @property['forward', @scenarioIdx] = true
    rescue AttributeOverwrite
    end
  })
  doc('depends', <<'EOT'
Specifies that the task cannot start before the specified tasks have been
finished.

By using the 'depends' attribute, the scheduling policy is automatically set
to ASAP. If both depends and precedes are used, the last policy counts.
EOT
      )
  example('Depends1')
  pattern(%w( _duration !calendarDuration ), lambda {
    setDurationAttribute('duration', @val[1])
  })
  doc('duration', <<'EOT'
Specifies the time the task should last. This is calendar time, not working
time. 7d means one week. If resources are specified they are allocated when
available. Availability of resources has no impact on the duration of the
task. It will always be the specified duration.

Tasks may not have subtasks if this attribute is used. Setting this attribute
will reset the [[effort]] and [[length]] attributes.
EOT
     )
  example('Durations')
  also(%w( effort length ))

  pattern(%w( _effort !workingDuration ), lambda {
    if @val[1] <= 0
      error('effort_zero', "Effort value must at least as large as the " +
                           "timing resolution " +
                           "(#{@project['scheduleGranularity'] / 60}min).",
            @sourceFileInfo[1], @property)
    end
    setDurationAttribute('effort', @val[1])
  })
  doc('effort', <<'EOT'
Specifies the effort needed to complete the task. An effort of ''''6d'''' (6
resource-days) can be done with 2 full-time resources in 3 working days. The
task will not finish before the allocated resources have contributed the
specified effort. Hence the duration of the task will depend on the
availability of the allocated resources. The specified effort value must be at
least as large as the [[timingresolution]].

WARNING: In almost all real world projects effort is not the product of time
and resources. This is only true if the task can be partitioned without adding
any overhead. For more information about this read ''The Mythical Man-Month'' by
Frederick P. Brooks, Jr.

Tasks may not have subtasks if this attribute is used. Setting this attribute
will reset the [[duration]] and [[length]] attributes. A task with an effort
value cannot be a [[milestone]].
EOT
     )
  example('Durations')
  also(%w( duration length ))

  pattern(%w( _effortdone !workingDuration ), lambda {
    @property['effortdone', @scenarioIdx] = @val[1]
  })
  level(:beta)
  doc('effortdone', <<'EOT'
Specifies how much effort of the task has already been completed. This can
only be used for [[effort]] based tasks and only if the task is scheduled in
[[schedulingmode|projection mode]]. No [[booking.task|bookings]] must be
specified for the scenario.  TaskJuggler is unable to create exact bookings
for the time period before the current date. All effort values prior to the
current date will be reported as zero.

This attribute forces the task to be scheduled in [[scheduling|ASAP mode]].
The task must have a predetermined [[start]] date.
EOT
     )
  also(%w( effort effortleft schedulingmode trackingscenario ))

  pattern(%w( _effortleft !workingDuration ), lambda {
    @property['effortleft', @scenarioIdx] = @val[1]
  })
  level(:beta)
  doc('effortleft', <<'EOT'
Specifies how much effort of the task is still not completed. This can
only be used for [[effort]] based tasks and only if the task is scheduled in
[[schedulingmode|projection mode]]. No [[booking.task|bookings]] must be
specified for the scenario.  TaskJuggler is unable to create exact bookings
for the time period before the current date. All effort values prior to the
current date will be reported as zero.

This attribute forces the task to be scheduled in [[scheduling|ASAP mode]].
The task must have a predetermined [[start]] date.
EOT
     )
  also(%w( effort effortdone schedulingmode trackingscenario ))

  pattern(%w( _end !valDate ), lambda {
    @property['end', @scenarioIdx] = @val[1]
    begin
      @property['forward', @scenarioIdx] = false
    rescue AttributeOverwrite
    end
  })
  doc('end', <<'EOT'
The end attribute provides a guideline to the scheduler when the task should
end. It will never end later, but it may end earlier when allocated
resources are not available that long. When an end date is provided for a
container task, it will be passed down to ALAP tasks that don't have a well
defined end criteria.

Setting an end date will implicitly set the scheduling policy for this task
to ALAP.
EOT
     )
  example('Export', '1')
  pattern(%w( _endcredit !number ), lambda {
    @property['charge', @scenarioIdx] =
      @property['charge', @scenarioIdx] +
      [ Charge.new(@val[1], :onEnd, @property, @scenarioIdx) ]
  })
  level(:deprecated)
  doc('endcredit', <<'EOT'
Specifies an amount that is credited to the accounts specified by the
[[chargeset]] attributes at the moment the task ends.
EOT
     )
  also('charge')
  example('Account', '1')
  pattern(%w( !flags ))
  doc('flags.task', <<'EOT'
Attach a set of flags. The flags can be used in logical expressions to filter
properties from the reports.
EOT
     )

  pattern(%w( !fail ))

  pattern(%w( _length !nonZeroWorkingDuration ), lambda {
    setDurationAttribute('length', @val[1])
  })
  doc('length', <<'EOT'
Specifies the duration of this task as working time, not calendar time. 7d
means 7 working days, or 7 times 8 hours (assuming default settings), not one
week.

A task with a length specification may have resource allocations. Resources
are allocated when they are available.  There is no guarantee that the task
will get any resources allocated.  The availability of resources has no impact
on the duration of the task. A time slot where none of the specified resources
is available is still considered working time, if there is no global vacation
and global working hours are defined accordingly.

For the length calculation, the global working hours and the global leaves
matter unless the task has [[shifts.task|shifts]] assigned. In the latter case
the working hours and leaves of the shift apply for the specified period to
determine if a slot is working time or not. If a resource has additional
working hours defined, it's quite possible that a task with a length of 5d
will have an allocated effort larger than 40 hours.  Resource working hours
only have an impact on whether an allocation is made or not for a particular
time slot. They don't effect the resulting duration of the task.

Tasks may not have subtasks if this attribute is used. Setting this attribute
will reset the [[duration]], [[effort]] and [[milestone]] attributes.
EOT
     )
  also(%w( duration effort ))

  pattern(%w( !limits ), lambda {
    checkContainer('limits')
    @property['limits', @scenarioIdx] = @val[0]
  })
  doc('limits.task', <<'EOT'
Set per-interval allocation limits for the task. This setting affects all allocations for this task.
EOT
     )
  example('Limits-1', '2')

  pattern(%w( _maxend !valDate ), lambda {
    @property['maxend', @scenarioIdx] = @val[1]
  })
  doc('maxend', <<'EOT'
Specifies the maximum wanted end time of the task. The value is not used
during scheduling, but is checked after all tasks have been scheduled. If the
end of the task is later than the specified value, then an error is reported.
EOT
     )

  pattern(%w( _maxstart !valDate ), lambda {
    @property['maxstart', @scenarioIdx] = @val[1]
  })
  doc('maxstart', <<'EOT'
Specifies the maximum wanted start time of the task. The value is not used
during scheduling, but is checked after all tasks have been scheduled. If the
start of the task is later than the specified value, then an error is
reported.
EOT
     )

  pattern(%w( _milestone ), lambda {
    setDurationAttribute('milestone')
  })
  doc('milestone', <<'EOT'
Turns the task into a special task that has no duration. You may not specify a
duration, length, effort or subtask for a milestone task.

A task that only has a start or an end specification and no duration
specification, inherited start or end dates, no dependencies or sub tasks,
will be recognized as milestone automatically.
EOT
     )

  pattern(%w( _minend !valDate ), lambda {
    @property['minend', @scenarioIdx] = @val[1]
  })
  doc('minend', <<'EOT'
Specifies the minimum wanted end time of the task. The value is not used
during scheduling, but is checked after all tasks have been scheduled. If the
end of the task is earlier than the specified value, then an error is
reported.
EOT
     )

  pattern(%w( _minstart !valDate ), lambda {
    @property['minstart', @scenarioIdx] = @val[1]
  })
  doc('minstart', <<'EOT'
Specifies the minimum wanted start time of the task. The value is not used
during scheduling, but is checked after all tasks have been scheduled. If the
start of the task is earlier than the specified value, then an error is
reported.
EOT
     )

  pattern(%w( _startcredit !number ), lambda {
    @property['charge', @scenarioIdx] +=
      [ Charge.new(@val[1], :onStart, @property, @scenarioIdx) ]
  })
  level(:deprecated)
  doc('startcredit', <<'EOT'
Specifies an amount that is credited to the account specified by the
[[chargeset]] attributes at the moment the task starts.
EOT
     )
  also('charge')
  pattern(%w( !taskPeriod ))

  pattern(%w( _precedes !taskPredList ), lambda {
    checkContainer('precedes')
      @property['precedes', @scenarioIdx] += @val[1]
    begin
      @property['forward', @scenarioIdx] = false
    rescue AttributeOverwrite
    end
  })
  doc('precedes', <<'EOT'
Specifies that the tasks with the specified IDs cannot start before this task
has been finished. If multiple IDs are specified, they must be separated by
commas. IDs must be either global or relative. A relative ID starts with a
number of '!'. Each '!' moves the scope to the parent task. Global IDs do not
contain '!', but have IDs separated by dots.

By using the 'precedes' attribute, the scheduling policy is automatically set
to ALAP. If both depends and precedes are used within a task, the last policy
counts.
EOT
     )

  pattern(%w( _priority $INTEGER ), lambda {
    if @val[1] < 0 || @val[1] > 1000
      error('task_priority', "Priority must have a value between 0 and 1000",
            @sourceFileInfo[1], @property)
    end
    @property['priority', @scenarioIdx] = @val[1]
  })
  doc('priority', <<'EOT'
Specifies the priority of the task. A task with higher priority is more
likely to get the requested resources. The default priority value of all tasks
is 500. Don't confuse the priority of a tasks with the importance or urgency
of a task. It only increases the chances that the task gets the requested
resources. It does not mean that the task happens earlier, though that is
usually the effect you will see. It also does not have any effect on tasks
that don't have any resources assigned (e.g. milestones).

For milestones, it will raise or lower the chances that tasks leading up the
milestone will get their resources over tasks with equal priority that compete
for the same resources.

This attribute is inherited by subtasks if specified prior to the definition
of the subtask.
EOT
     )
  arg(1, 'value', 'Priority value (1 - 1000)')
  example('Priority')

  pattern(%w( _projectid $ID ), lambda {
    unless @project['projectids'].include?(@val[1])
      error('unknown_projectid', "Unknown project ID #{@val[1]}",
            @sourceFileInfo[1])
    end
    begin
      @property['projectid', @scenarioIdx] = @val[1]
    rescue AttributeOverwrite
      # This attribute always overwrites the implicitly provided ID.
    end
  })
  doc('projectid.task', <<'EOT'
In larger projects it may be desirable to work with different project IDs for
parts of the project. This attribute assignes a new project ID to this task and
all subsequently defined sub tasks. The project ID needs to be declared first using [[projectid]] or [[projectids]].
EOT
     )

  pattern(%w( _responsible !resourceList ), lambda {
    @property['responsible', @scenarioIdx] += @val[1]
    @property['responsible', @scenarioIdx].uniq!
  })
  doc('responsible', <<'EOT'
The ID of the resource that is responsible for this task. This value is for
documentation purposes only. It's not used by the scheduler.
EOT
     )

  pattern(%w( _scheduled ), lambda {
    @property['scheduled', @scenarioIdx] = true
  })
  doc('scheduled', <<'EOT'
It specifies that the task can be ignored for scheduling in the scenario. This
option only makes sense if you provide all resource
[[booking.resource|bookings]] manually. Without booking statements, the task
will be reported with 0 effort and no resources assigned. If the task is not a
milestone, has no effort, length or duration criteria, the start and end date
will be derived from the first and last booking in case those dates are not
supplied.
EOT
     )

  pattern(%w( _scheduling !schedulingDirection ), lambda {
    if @val[1] == 'alap'
      begin
        @property['forward', @scenarioIdx] = false
      rescue AttributeOverwrite
      end
    elsif @val[1] == 'asap'
      begin
        @property['forward', @scenarioIdx] = true
      rescue AttributeOverwrite
      end
    end
  })
  doc('scheduling', <<'EOT'
Specifies the scheduling policy for the task. A task can be scheduled from
start to end (As Soon As Possible, ASAP) or from end to start (As Late As
Possible, ALAP).

A task can be scheduled from start to end (ASAP mode) when it has a hard
(start) or soft (depends) criteria for the start time. A task can be scheduled
from end to start (ALAP mode) when it has a hard (end) or soft (precedes)
criteria for the end time.

Some task attributes set the scheduling policy implicitly. This attribute can
be used to explicitly set the scheduling policy of the task to a certain
direction. To avoid it being overwritten again by an implicit attribute, this
attribute should always be the last attribute of the task.

A random mixture of ASAP and ALAP tasks can have unexpected side effects on
the scheduling of the project. It increases significantly the scheduling
complexity and results in much longer scheduling times. Especially in projects
with many hundreds of tasks, the scheduling time of a project with a mixture of
ASAP and ALAP times can be 2 to 10 times longer. When the project contains
chains of ALAP and ASAP tasks, the tasks further down the dependency chain will
be served much later than other non-chained tasks, even when they have a much
higher priority. This can result in situations where high priority tasks do
not get their resources, even though the parallel competing tasks have a much
lower priority.

ALAP tasks may not have [[booking.task|bookings]], since the first booked slot
determines the start date of the task and prevents it from being scheduled
from end to start.

As a general rule, try to avoid ALAP tasks whenever possible. Have a close
eye on tasks that have been switched implicitly to ALAP mode because the
end attribute comes after the start attribute.
EOT
     )

  pattern(%w( _schedulingmode !schedulingMode ), lambda {
    @property['projectionmode', @scenarioIdx] = (@val[1] == 'projection')
  })
  level(:beta)
  doc('schedulingmode', <<'EOT'
The scheduling mode controls how the scheduler assigns resources to this task.
In planning mode, resources are allocated before and after the current date.
In projection mode, resources are only allocated after the current date. In
this mode, any resource activity prior to the current date must be provided
with [[booking.task|bookings]]. Alternatively, the [[effortdone]] or
[[effortleft]] attribute can be used.

This scheduling mode is automatically set to projection mode when the [[trackingscenario]] is set. However, the setting can be overwritten by using this attribute.
EOT
     )

  pattern(%w( !taskShiftAssignments !shiftAssignments ), lambda {
    checkContainer('shift')
    # Set same value again to set the 'provided' state for the attribute.
    begin
      @property['shifts', @scenarioIdx] = @shiftAssignments
    rescue AttributeOverwrite
      # Multiple shift assignments are a common idiom, so don't warn about
      # them.
    end
    @shiftAssignments = nil
  })
  level(:deprecated)
  doc('shift.task', <<'EOT'
This keyword has been deprecated. Please use [[shifts.task|shifts
(task)]] instead.
EOT
     )
  also('shifts.task')

  pattern(%w( !taskShiftsAssignments !shiftAssignments ), lambda {
    checkContainer('shifts')
    begin
      @property['shifts', @scenarioIdx] = @shiftAssignments
    rescue AttributeOverwrite
      # Multiple shift assignments are a common idiom, so don't warn about
      # them.
    end
    @shiftAssignments = nil
  })
  doc('shifts.task', <<'EOT'
Limits the working time for this task during the specified interval
to the working hours of the given shift. Multiple shifts can be defined, but
shift intervals may not overlap. This is an additional working time
restriction on top of the working hours of the allocated resources. It does not
replace the resource working hour restrictions. For a resource to be assigned
to a time slot, both the respective task shift as well as the resource working
hours must declare the time slot as duty slot.
EOT
      )

  pattern(%w( _start !valDate), lambda {
    @property['start', @scenarioIdx] = @val[1]
    begin
      @property['forward', @scenarioIdx] = true
    rescue AttributeOverwrite
    end
  })
  doc('start', <<'EOT'
The start attribute provides a guideline to the scheduler when the task should
start. It will never start earlier, but it may start later when allocated
resources are not available immediately. When a start date is provided for a
container task, it will be passed down to ASAP tasks that don't have a well
defined start criteria.

Setting a start date will implicitly set the scheduling policy for this task
to ASAP.
EOT
     )
  also(%w( end period.task maxstart minstart scheduling ))

  pattern(%w( !warn ))

  # Other attributes will be added automatically.
end

#rule_taskShiftAssignmentsObject



6807
6808
6809
6810
6811
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6807

def rule_taskShiftAssignments
  pattern(%w( _shift ), lambda {
    @shiftAssignments = @property['shifts', @scenarioIdx]
  })
end

#rule_taskShiftsAssignmentsObject



6813
6814
6815
6816
6817
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6813

def rule_taskShiftsAssignments
  pattern(%w( _shifts ), lambda {
    @shiftAssignments = @property['shifts', @scenarioIdx]
  })
end

#rule_textReportObject



6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6819

def rule_textReport
  pattern(%w( !textReportHeader !reportBody ), lambda {
    @property = @property.parent
  })
  doc('textreport', <<'EOT'
This report consists of 5 [[Rich_Text_Attributes|Rich Text]] sections, a header, a center section with a
left and right margin and a footer. The sections may contain the output of
other defined reports.
EOT
     )
  example('textreport')
end

#rule_textReportHeaderObject



6832
6833
6834
6835
6836
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6832

def rule_textReportHeader
  pattern(%w( _textreport !optionalID !reportName ), lambda {
    newReport(@val[1], @val[2], :textreport, @sourceFileInfo[0])
  })
end

#rule_timeformatObject



6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6838

def rule_timeformat
  pattern(%w( _timeformat $STRING ), lambda {
    @val[1]
  })
  doc('timeformat', <<'EOT'
Determines how time specifications in reports look like.
EOT
     )
  arg(1, 'format', <<'EOT'
Ordinary characters placed in the format string are copied without
conversion. Conversion specifiers are introduced by a `%' character, and are
replaced as follows:

* ''''%a''''  The abbreviated weekday name according to the current locale.

* ''''%A''''  The full weekday name according to the current locale.

* ''''%b''''  The abbreviated month name according to the current locale.

* ''''%B''''  The full month name according to the current locale.

* ''''%c''''  The preferred date and time representation for the current locale.

* ''''%C''''  The century number (year/100) as a 2-digit integer. (SU)

* ''''%d''''  The day of the month as a decimal number (range 01 to 31).

* ''''%e''''  Like ''''%d'''', the day of the month as a decimal number, but a
leading zero is replaced by a space. (SU)

* ''''%E''''  Modifier: use alternative format, see below. (SU)

* ''''%F''''  Equivalent to ''''%Y-%m-%d'''' (the ISO 8601 date format). (C99)

* ''''%G''''  The ISO 8601 year with century as a decimal number. The 4-digit
year corresponding to the ISO week number (see %V). This has the same format
and value as ''''%y'''', except that if the ISO week number belongs to the
previous or next year, that year is used instead. (TZ)

* ''''%g''''  Like %G, but without century, i.e., with a 2-digit year (00-99).
(TZ)

* ''''%h''''  Equivalent to ''''%b''''. (SU)

* ''''%H''''  The hour as a decimal number using a 24-hour clock (range 00 to
23).

* ''''%I''''  The hour as a decimal number using a 12-hour clock (range 01 to
12).

* ''''%j''''  The day of the year as a decimal number (range 001 to 366).

* ''''%k''''  The hour (24-hour clock) as a decimal number (range 0 to 23);
single digits are preceded by a blank. (See also ''''%H''''.) (TZ)

* ''''%l''''  The hour (12-hour clock) as a decimal number (range 1 to 12);
single digits are preceded by a blank. (See also ''''%I''''.) (TZ)

* ''''%m''''  The month as a decimal number (range 01 to 12).

* ''''%M''''  The minute as a decimal number (range 00 to 59).

* ''''%n''''  A newline character. (SU)

* ''''%O''''  Modifier: use alternative format, see below. (SU)

* ''''%p''''  Either 'AM' or 'PM' according to the given time value, or the
corresponding strings for the current locale. Noon is treated as `pm' and
midnight as 'am'.

* ''''%P''''  Like %p but in lowercase: 'am' or 'pm' or ''''%a''''
corresponding string for the current locale. (GNU)

* ''''%r''''  The time in a.m. or p.m. notation. In the POSIX locale this is
equivalent to ''''%I:%M:%S %p''''. (SU)

* ''''%R''''  The time in 24-hour notation (%H:%M). (SU) For a version
including the seconds, see ''''%T'''' below.

* ''''%s''''  The number of seconds since the Epoch, i.e., since 1970-01-01
00:00:00 UTC.  (TZ)

* ''''%S''''  The second as a decimal number (range 00 to 61).

* ''''%t''''  A tab character. (SU)

* ''''%T''''  The time in 24-hour notation (%H:%M:%S). (SU)

* ''''%u''''  The day of the week as a decimal, range 1 to 7, Monday being 1.
See also ''''%w''''. (SU)

* ''''%U''''  The week number of the current year as a decimal number, range
00 to 53, starting with the first Sunday as the first day of week 01. See also
''''%V'''' and ''''%W''''.

* ''''%V''''  The ISO 8601:1988 week number of the current year as a decimal
number, range 01 to 53, where week 1 is the first week that has at least 4
days in the current year, and with Monday as the first day of the week. See
also ''''%U'''' and ''''%W''''. %(SU)

* ''''%w''''  The day of the week as a decimal, range 0 to 6, Sunday being 0. See also ''''%u''''.

* ''''%W''''  The week number of the current %year as a decimal number, range
00 to 53, starting with the first Monday as the first day of week 01.

* ''''%x''''  The preferred date representation for the current locale without
the time.

* ''''%X''''  The preferred time representation for the current locale without
the date.

* ''''%y''''  The year as a decimal number without a century (range 00 to 99).

* ''''%Y''''   The year as a decimal number including the century.

* ''''%z''''   The time zone as hour offset from GMT. Required to emit
RFC822-conformant dates (using ''''%a, %d %%b %Y %H:%M:%S %%z''''). (GNU)

* ''''%Z''''  The time zone or name or abbreviation.

* ''''%+''''  The date and time in date(1) format. (TZ)

* ''''%%''''  A literal ''''%'''' character.

Some conversion specifiers can be modified by preceding them by the E or O
modifier to indicate that an alternative format should be used. If the
alternative format or specification does not exist for the current locale, the
behavior will be as if the unmodified conversion specification were used.

(SU) The Single Unix Specification mentions %Ec, %EC, %Ex, %%EX, %Ry, %EY,
%Od, %Oe, %OH, %OI, %Om, %OM, %OS, %Ou, %OU, %OV, %Ow, %OW, %Oy, where the
effect of the O modifier is to use alternative numeric symbols (say, Roman
numerals), and that of the E modifier is to use a locale-dependent alternative
representation.

This documentation of the timeformat attribute has been taken from the man page
of the GNU strftime function.
EOT
     )

end

#rule_timeIntervalObject



6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6980

def rule_timeInterval
  pattern([ '$TIME', '_-', '$TIME' ], lambda {
    if @val[0] >= @val[2]
      error('time_interval',
            "End time of interval must be larger than start time",
            @sourceFileInfo[0])
    end
    [ @val[0], @val[2] ]
  })
end

#rule_timeSheetObject



6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 6991

def rule_timeSheet
  pattern(%w( !timeSheetHeader !timeSheetBody ), lambda {
    @timeSheet
  })
  doc('timesheet', <<'EOT'
A time sheet record can be used to capture the current status of the tasks
assigned to a specific resource and the achieved progress for a given period
of time. The status is assumed to be for the end of this time period. There
must be a separate time sheet record for each resource per period. Different
resources can use different reporting periods and reports for the same
resource may have different reporting periods as long as they don't overlap.
For the time after the last time sheet, TaskJuggler will project the result
based on the plan data. For periods without a time sheet record prior to the
last record for this resource, TaskJuggler assumes that no work has been done.
The work is booked for the scenario specified by [[trackingscenario]].

The intended use for time sheets is to have all resources report a time sheet
every day, week or month. All time sheets can be added to the project plan.
The status information is always used to determine the current status of the
project. The [[work]], [[remaining]] and [[end.timesheet|end]] attributes are
ignored if there are also [[booking.task|bookings]] for the resource in the
time sheet period. The non-ignored attributes of the time sheets will be
converted into [[booking.task|booking]] statements internally. These bookings
can then be [[export|exported]] into a file which can then be added to the
project again. This way, you can use time sheets to incrementally record
progress of your project. There is a possibility that time sheets conflict
with other data in the plan. In case TaskJuggler cannot automatically resolve
them, these conflicts have to be manually resolved by either changing the plan
or the time sheet.

The status messages are interpreted as [[journalentry|journal entries]]. The
alert level will be evaluated and the current state of the project can be put
into a dashboard using the ''''alert'''' and ''''alertmessage'''' [[columnid|
columns]].

Currently, the provided effort values and dates are not yet used to
automatically update the plan data. This feature will be added in future
versions.
EOT
     )
  example('TimeSheet1', '1')
end

#rule_timeSheetAttributesObject



7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7034

def rule_timeSheetAttributes
  optional
  repeatable

  pattern(%w( !tsNewTaskHeader !tsTaskBody ), lambda {
    @property = nil
    @timeSheetRecord = nil
  })
  doc('newtask', <<'EOT'
The keyword can be used to request a new task to the project. If the task ID
requires further parent tasks that don't exist yet, these tasks will be
requested as well. If the task exists already, an error will be generated. The
newly requested task can be used immediately to report progress and status
against it. These tasks will not automatically be added to the project plan.
The project manager has to manually create them after reviewing the request
during the time sheet reviews.
EOT
     )
  example('TimeSheet1', '3')

  pattern(%w( _shift !shiftId ), lambda {
    #TODO
  })
  doc('shift.timesheet', <<'EOT'
Specifies an alternative [[shift]] for the time sheet period. This shift will
override any existing working hour definitions for the resource. It will not
override already declared [[leaves]] though.

The primary use of this feature is to let the resources report different total
work time for the report period.
EOT
     )

  pattern(%w( !tsStatus ))

  pattern(%w( !tsTaskHeader !tsTaskBody ), lambda {
    @property = nil
    @timeSheetRecord = nil
  })
  doc('task.timesheet', <<'EOT'
Specifies an existing task that progress and status should be reported
against.
EOT
     )
  example('TimeSheet1', '4')
end

#rule_timeSheetBodyObject



7088
7089
7090
7091
7092
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7088

def rule_timeSheetBody
  pattern(%w( _{ !timeSheetAttributes _} ), lambda {

  })
end

#rule_timeSheetFileObject



7081
7082
7083
7084
7085
7086
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7081

def rule_timeSheetFile
  pattern(%w( !timeSheet . ), lambda {
    @val[0]
  })
  lastSyntaxToken(1)
end

#rule_timeSheetHeaderObject



7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7094

def rule_timeSheetHeader
  pattern(%w( _timesheet !resourceId !valIntervalOrDate ), lambda {
    @sheetAuthor = @val[1]
    @property = nil
    unless @sheetAuthor.leaf?
      error('ts_group_author',
            'A resource group cannot file a time sheet',
            @sourceFileInfo[1])
    end
    unless (scenarioIdx = @project['trackingScenarioIdx'])
      error('ts_no_tracking_scenario',
            'No trackingscenario defined.')
    end
    # Currently time sheets are hardcoded for scenario 0.
    @timeSheet = TimeSheet.new(@sheetAuthor, @val[2], scenarioIdx)
    @timeSheet.sourceFileInfo = @sourceFileInfo[0]
    @project.timeSheets << @timeSheet
  })
end

#rule_timeSheetReportObject



7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7114

def rule_timeSheetReport
  pattern(%w( !tsReportHeader !tsReportBody ), lambda {
    @property = nil
  })
  doc('timesheetreport', <<'EOT'
For projects that flow mostly according to plan, TaskJuggler already knows
much of the information that should be contained in the time sheets. With this
property, you can generate a report that contains drafts of the time sheets
for one or more resources. The time sheet drafts will be for the
specified report period and the specified [trackingscenario].
EOT
     )
end

#rule_timezoneObject



7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7128

def rule_timezone
  pattern(%w( _timezone !validTimeZone ), lambda{
    TjTime.setTimeZone(@val[1])
    @project['timezone'] = @val[1]
  })
  doc('timezone', <<'EOT'
Sets the default time zone of the project. All dates and times that have no
time zones specified will be assumed to be in this time zone. If no time zone
is specified for the project, UTC is assumed.

The project start and end time are not affected by this setting. They are
always considered to be UTC unless specified differently.

In case the specified time zone is not hour-aligned with UTC, the
[[timingresolution]] will automatically be decreased accordingly. Do not
change the timingresolution after you've set the time zone!

Changing the time zone will reset the [[workinghours.project|working hours]]
to the default times. It's recommended that you declare your working hours
after the time zone.
EOT
      )
  arg(1, 'zone', <<'EOT'
Time zone to use. E. g. 'Europe/Berlin' or 'America/Denver'. Don't use the 3
letter acronyms. See
[http://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones Wikipedia] for
possible values.
EOT
     )
end

#rule_traceReportObject



7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7159

def rule_traceReport
  pattern(%w( !traceReportHeader !reportBody ), lambda {
    @property = @property.parent
  })
  doc('tracereport', <<'EOT'
The trace report works noticeably different than all other TaskJuggler
reports. It uses a CSV file to track the values of the selected attributes.
Each time ''''tj3'''' is run with the ''''--add-trace'''' option, a new set of
values is appended to the CSV file. The first column of the CSV file holds the
date when the snapshot was taken. This is either the current date or the
''''now'''' date if provided. There is no need to specify CSV as output format
for the report. You can either use these tracked values directly by specifying other report formats or by importing the CSV file into another program.

The first column always contains the current date when that
table row was added. All subsequent columns can be defined by the user with
the [[columns]] attribute. This column set is then repeated for all properties
that are not hidden by [[hideaccount]], [[hideresource]] and [[hidetask]]. By
default, all properties are excluded. You must provide at least one of the
''''hide...'''' attributes to select the properties you want to have included
in the report. Please be aware that the total number of columns is the product of
attributes defined with [[columns]] times the number of included properties.
Select your values carefully or you will end up with very large reports.

The column headers can be customized by using the [[title.column|title]]
attribute.  When you include multiple properties, these headers are not unique
unless you include mini-queries to modify them based on the property the
column is representing.  You can use the queries
''''<nowiki><-id-></nowiki>'''', ''''<nowiki><-name-></nowiki>'''',
''''<nowiki><-scenario-></nowiki>'''' and
''''<nowiki><-attribute-></nowiki>''''. ''''<nowiki><-id-></nowiki>'''' is
replaced with the ID of the property, ''''<nowiki><-name-></nowiki>'''' with
the name and so on.

You can change the set of tracked values over time. Old values will be
preserved and the corresponding columns will be the last ones in the CSV file.

When other formats are requested, the CSV file is read in and a report that
shows the tracked values over time will be generated. The CSV file may contain
all kinds of values that are being tracked. Report formats that don't support
a mix of different values will just show the values of the second column.

The values in the CSV files are fixed units and cannot be formatted. Effort
values are always in resource-days. This allows other software to interpret
the file without any need for additional context information.

The HTML version generates SVG graphs that are embedded in the HTML page.
These graphs are only visible if the web browser supports HTML5. This is true
for the latest generation of browsers, but older browsers may not support this
format.
EOT
     )
  example('TraceReport')
end

#rule_traceReportHeaderObject



7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7213

def rule_traceReportHeader
  pattern(%w( _tracereport !optionalID !reportName ), lambda {
    newReport(@val[1], @val[2], :tracereport, @sourceFileInfo[0]) do
      # The top-level always inherits the global timeFormat setting. This is
      # not desirable in this case, so we ignore this.
      if (@property.level == 0 && !@property.provided('timeFormat')) ||
         (@property.level > 0 && !@property.modified?('timeFormat'))
        # CSV readers such of Libre-/OpenOffice can't deal with time zones. We
        # probably also don't need seconds.
        @property.set('timeFormat', '%Y-%m-%d-%H:%M')
      end
      unless @property.modified?('columns')
        # Set the default columns for this report.
        %w( end ).each do |col|
          @property.get('columns') <<
          TableColumnDefinition.new(col, columnTitle(col))
        end
      end
      # Hide all accounts.
      unless @property.modified?('hideAccount')
        @property.set('hideAccount',
                      LogicalExpression.new(LogicalOperation.new(1)))
      end
      unless @property.modified?('sortAccounts')
        @property.set('sortAccounts',
                      [ [ 'tree', true, -1 ],
                        [ 'seqno', true, -1 ] ])
      end
      # Show all tasks, sorted by tree, start-up, seqno-up.
      unless @property.modified?('hideTask')
        @property.set('hideTask',
                      LogicalExpression.new(LogicalOperation.new(0)))
      end
      unless @property.modified?('sortTasks')
        @property.set('sortTasks',
                      [ [ 'tree', true, -1 ],
                        [ 'start', true, 0 ],
                        [ 'seqno', true, -1 ] ])
      end
      # Show no resources, but set sorting to id-up.
      unless @property.modified?('hideResource')
        @property.set('hideResource',
                      LogicalExpression.new(LogicalOperation.new(1)))
      end
      unless @property.modified?('sortResources')
        @property.set('sortResources', [ [ 'id', true, -1 ] ])
      end
    end
  })
end

#rule_tsNewTaskHeaderObject



7264
7265
7266
7267
7268
7269
7270
7271
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7264

def rule_tsNewTaskHeader
  pattern(%w( _newtask !taskIdUnverifd $STRING ), lambda {
    @timeSheetRecord = TimeSheetRecord.new(@timeSheet, @val[1])
    @timeSheetRecord.name = @val[2]
    @timeSheetRecord.sourceFileInfo = @sourceFileInfo[0]
  })
  arg(1, 'task', 'ID of the new task')
end

#rule_tsReportAttributesObject



7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7302

def rule_tsReportAttributes
  optional
  repeatable

  pattern(%w( !hideresource ))
  pattern(%w( !hidetask ))
  pattern(%w( !reportEnd ))
  pattern(%w( !reportPeriod ))
  pattern(%w( !reportStart ))
  pattern(%w( !sortResources ))
  pattern(%w( !sortTasks ))
end

#rule_tsReportBodyObject



7315
7316
7317
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7315

def rule_tsReportBody
  optionsRule('tsReportAttributes')
end

#rule_tsReportHeaderObject



7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7273

def rule_tsReportHeader
  pattern(%w( _timesheetreport !optionalID $STRING ), lambda {
    newReport(@val[1], @val[2], :timeSheet, @sourceFileInfo[0]) do
      @property.set('formats', [ :tjp ])

      unless (scenarioIdx = @project['trackingScenarioIdx'])
        error('ts_no_tracking_scenario',
              'You must have a tracking scenario defined to use time sheets.')
      end
      @property.set('scenarios', [ scenarioIdx ])
      # Show all tasks, sorted by seqno-up.
      @property.set('hideTask',
                    LogicalExpression.new(LogicalOperation.new(0)))
      @property.set('sortTasks', [ [ 'seqno', true, -1 ] ])
      # Show all resources, sorted by seqno-up.
      @property.set('hideResource',
                    LogicalExpression.new(LogicalOperation.new(0)))
      @property.set('sortResources', [ [ 'seqno', true, -1 ] ])
      @property.set('loadUnit', :hours)
      @property.set('definitions', [])
    end
  })
  arg(2, 'file name', <<'EOT'
The name of the time sheet report file to generate. It must end with a .tji
extension, or use . to use the standard output channel.
EOT
     )
end

#rule_tsStatusObject



7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7370

def rule_tsStatus
  pattern(%w( !tsStatusHeader !tsStatusBody ))
  doc('status.timesheet', <<'EOT'
The status attribute can be used to describe the current status of the task or
resource. The content of the status messages is added to the project journal.
The status section is optional for tasks that have been worked on less than
one day during the report interval.
EOT
     )
  arg(2, 'headline', <<'EOT'
A short headline for the status. Must be 60 characters or shorter.
EOT
     )
  example('TimeSheet1', '4')
end

#rule_tsStatusAttributesObject



7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7319

def rule_tsStatusAttributes
  optional
  repeatable

  pattern(%w( !details ))

  pattern(%w( _flags !flagList ), lambda {
    @val[1].each do |flag|
      next if @journalEntry.flags.include?(flag)

      @journalEntry.flags << flag
    end
  })
  doc('flags.timesheet', <<'EOT'
Time sheet entries can have flags attached to them. These can be used to
include only entries in a report that have a certain flag.
EOT
     )

  pattern(%w( !summary ))
end

#rule_tsStatusBodyObject



7341
7342
7343
7344
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7341

def rule_tsStatusBody
  optional
  pattern(%w( _{ !tsStatusAttributes _} ))
end

#rule_tsStatusHeaderObject



7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7346

def rule_tsStatusHeader
  pattern(%w( _status !alertLevel $STRING ), lambda {
    if @val[2].length > 120
      error('ts_headline_too_long',
            "The headline must be 120 or less characters long. This one " +
            "has #{@val[2].length} characters.", @sourceFileInfo[2])
    end
    if @val[2] == 'Your headline here!'
      error('ts_no_headline',
            "'Your headline here!' is not a valid headline",
            @sourceFileInfo[2])
    end
    @journalEntry = JournalEntry.new(@project['journal'],
                                     @timeSheet.interval.end,
                                     @val[2],
                                     @property || @timeSheet.resource,
                                     @sourceFileInfo[0])
    @journalEntry.alertLevel = @val[1]
    @journalEntry.timeSheetRecord = @timeSheetRecord
    @journalEntry.author = @sheetAuthor
    @timeSheetRecord.status = @journalEntry if @timeSheetRecord
  })
end

#rule_tsTaskAttributesObject



7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7386

def rule_tsTaskAttributes
  optional
  repeatable

  pattern(%w( _end !valDate ), lambda {
    if @val[1] < @timeSheet.interval.start
      error('ts_end_too_early',
            "The expected task end date must be after the start date of " +
            "this time sheet report.", @sourceFileInfo[1])
    end
    @timeSheetRecord.expectedEnd = @val[1]
  })
  doc('end.timesheet', <<'EOT'
The expected end date for the task. This can only be used for duration based
tasks. For effort based tasks [[remaining]] has to be used.
EOT
     )
  example('TimeSheet1', '5')

  pattern(%w( _priority $INTEGER ), lambda {
    priority = @val[1]
    if priority < 1 || priority > 1000
      error('ts_bad_priority',
            "Priority value #{priority} must be between 1 and 1000.",
            @sourceFileInfo[1])
    end
    @timeSheetRecord.priority = priority
  })
  doc('priority.timesheet', <<'EOT'
The priority is a value between 1 and 1000. It is used to determine the
sequence of tasks when converting [[work]] to [[booking.task|bookings]]. Tasks
that need to finish earlier in the period should have a high priority, tasks
that end later in the period should have a low priority. For tasks that don't
get finished in the reported period the priority should be set to 1.
EOT
     )

  pattern(%w( _remaining !workingDuration ), lambda {
    @timeSheetRecord.remaining = @val[1]
  })
  doc('remaining', <<'EOT'
The remaining effort for the task. This value is ignored if there are
[[booking.task|bookings]] for the resource that overlap with the time sheet
period.  If there are no bookings, the value is compared with the [[effort]]
specification of the task. If there is a mismatch between the accumulated effort
specified with bookings, [[work]] and [[remaining]] on one side and the
specified [[effort]] on the other, a warning is generated.

This attribute can only be used with tasks that are effort based. Duration
based tasks need to have an [[end.timesheet|end]] attribute.
EOT
     )
  example('TimeSheet1', '6')

  pattern(%w( !tsStatus ))

  pattern(%w( _work !workingDurationPercent ), lambda {
    @timeSheetRecord.work = @val[1]
  })
  doc('work', <<'EOT'
The amount of time that the resource has spent with the task during the
reported period. This value is ignored when there are
[[booking.task|bookings]] for the resource overlapping with the time sheet
period. If there are no bookings, TaskJuggler will try to convert the work
specification into bookings internally before the actual scheduling is
started.

Every task listed in the time sheet needs to have a work attribute. The total
accumulated work time that is reported must match exactly the total working
hours for the resource for that period.

If a resource has no vacation during the week that is reported and it has a
regular 40 hour work week, exactly 40 hours total or 5 working days have to be
reported.
EOT
     )
  example('TimeSheet1', '4')
end

#rule_tsTaskBodyObject



7465
7466
7467
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7465

def rule_tsTaskBody
  pattern(%w( _{ !tsTaskAttributes _} ))
end

#rule_tsTaskHeaderObject



7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7469

def rule_tsTaskHeader
  pattern(%w( _task !taskId ), lambda {
    @property = @val[1]
    unless @property.leaf?
      error('ts_task_not_leaf',
            'You cannot specify a task that has sub tasks here.',
            @sourceFileInfo[1], @property)
    end

    @timeSheetRecord = TimeSheetRecord.new(@timeSheet, @property)
    @timeSheetRecord.sourceFileInfo = @sourceFileInfo[0]
  })
  arg(1, 'task', 'ID of an already existing task')
end

#rule_undefResourceIdObject



7484
7485
7486
7487
7488
7489
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7484

def rule_undefResourceId
  pattern(%w( $ID ), lambda {
    (@resourceprefix.empty? ? '' : @resourceprefix + '.') + @val[0]
  })
  arg(0, 'resource', 'The ID of a defined resource')
end

#rule_vacationNameObject



7491
7492
7493
7494
7495
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7491

def rule_vacationName
  optional
  pattern(%w( $STRING )) # We just throw the name away
  arg(0, 'name', 'An optional name or reason for the leave')
end

#rule_valDateObject



7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7497

def rule_valDate
  pattern(%w( !date ), lambda {
    if @val[0] < @project['start'] || @val[0] > @project['end']
      error('date_in_range',
            "Date #{@val[0]} must be within the project time frame " +
            "#{@project['start']}  - #{@project['end']}",
            @sourceFileInfo[0])
    end
    @val[0]
  })
end

#rule_validTimeZoneObject



7509
7510
7511
7512
7513
7514
7515
7516
7517
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7509

def rule_validTimeZone
  pattern(%w( $STRING ), lambda {
    unless TjTime.checkTimeZone(@val[0])
      error('bad_time_zone', "#{@val[0]} is not a known time zone",
            @sourceFileInfo[0])
    end
    @val[0]
  })
end

#rule_valIntervalObject



7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7557

def rule_valInterval
  pattern(%w( !date !intervalEnd ), lambda {
    mode = @val[1][0]
    endSpec = @val[1][1]
    if mode == 0
      unless @val[0] < endSpec
        error('start_before_end', "The end date (#{endSpec}) must be after " +
              "the start date (#{@val[0]}).", @sourceFileInfo[1])
      end
      iv = TimeInterval.new(@val[0], endSpec)
    else
      iv = TimeInterval.new(@val[0], @val[0] + endSpec)
    end
    checkInterval(iv)
    iv
  })
  doc('interval1', <<'EOT'
There are two ways to specify a date interval. The start and end date must lie within the specified project period.

The first is the most obvious. A date interval consists of a start and end
DATE. Watch out for end dates without a time specification! Date
specifications are 0 extended. An end date without a time is expanded to
midnight that day. So the day of the end date is not included in the interval!
The start and end dates must be separated by a hyphen character.

The second form specifies the start date and an interval duration. The
duration must be prefixed by a plus character.
EOT
     )
end

#rule_valIntervalOrDateObject



7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7519

def rule_valIntervalOrDate
  pattern(%w( !date !intervalOptionalEnd ), lambda {
    if @val[1]
      mode = @val[1][0]
      endSpec = @val[1][1]
      if mode == 0
        unless @val[0] < endSpec
          error('start_before_end', "The end date (#{endSpec}) must be " +
                "after the start date (#{@val[0]}).",
                @sourceFileInfo[1])
        end
        iv = TimeInterval.new(@val[0], endSpec)
      else
        iv = TimeInterval.new(@val[0], @val[0] + endSpec)
      end
    else
      iv = TimeInterval.new(@val[0], @val[0].sameTimeNextDay)
    end
    checkInterval(iv)
    iv
  })
  doc('interval4', <<'EOT'
There are three ways to specify a date interval. The first is the most
obvious. A date interval consists of a start and end DATE. Watch out for end
dates without a time specification! Date specifications are 0 extended. An
end date without a time is expanded to midnight that day. So the day of the
end date is not included in the interval! The start and end dates must be separated by a hyphen character.

In the second form, the end date is omitted. A 24 hour interval is assumed.

The third form specifies the start date and an interval duration. The duration must be prefixed by a plus character.

The start and end date of the interval must be within the specified project
time frame.
EOT
     )
end

#rule_valIntervalsObject



7588
7589
7590
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7588

def rule_valIntervals
  listRule('moreValIntervals', '!valIntervalOrDate')
end

#rule_warnObject



7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7592

def rule_warn
  pattern(%w( _warn !logicalExpression ), lambda {
    begin
      @property.set('warn', @property.get('warn') + [ @val[1] ])
    rescue AttributeOverwrite
    end
  })
  doc('warn', <<'EOT'
The warn attribute adds a [[logicalexpression|logical expression]] to the
property. The condition described by the logical expression is checked after
the scheduling and a warning is generated if the condition evaluates to true.
This attribute is primarily intended for testing purposes.
EOT
     )
end

#rule_weekdayObject



7609
7610
7611
7612
7613
7614
7615
7616
7617
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7609

def rule_weekday
  pattern(%w( _sun ), lambda { 0 })
  pattern(%w( _mon ), lambda { 1 })
  pattern(%w( _tue ), lambda { 2 })
  pattern(%w( _wed ), lambda { 3 })
  pattern(%w( _thu ), lambda { 4 })
  pattern(%w( _fri ), lambda { 5 })
  pattern(%w( _sat ), lambda { 6 })
end

#rule_weekDayIntervalObject



7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7619

def rule_weekDayInterval
  pattern(%w( !weekday !weekDayIntervalEnd ), lambda {
    weekdays = Array.new(7, false)
    if @val[1].nil?
      weekdays[@val[0]] = true
    else
      d = @val[0]
      loop do
        weekdays[d] = true
        break if d == @val[1]
        d = (d + 1) % 7
      end
    end

    weekdays
  })
  arg(0, 'weekday', 'Weekday (sun - sat)')
end

#rule_weekDayIntervalEndObject



7638
7639
7640
7641
7642
7643
7644
7645
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7638

def rule_weekDayIntervalEnd
  optional
  pattern([ '_-', '!weekday' ], lambda {
    @val[1]
  })
  arg(1, 'end weekday',
      'Weekday (sun - sat). It is included in the interval.')
end

#rule_workingDurationObject



7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7660

def rule_workingDuration
  pattern(%w( !number !durationUnit ), lambda {
    convFactors = [ 60, # minutes
                    60 * 60, # hours
                    60 * 60 * @project['dailyworkinghours'], # days
                    60 * 60 * @project['dailyworkinghours'] *
                    (@project.weeklyWorkingDays), # weeks
                    60 * 60 * @project['dailyworkinghours'] *
                    (@project['yearlyworkingdays'] / 12), # months
                    60 * 60 * @project['dailyworkinghours'] *
                    @project['yearlyworkingdays'] # years
                  ]
    # The result will always be in number of time slots.
    (@val[0] * convFactors[@val[1]] /
     @project['scheduleGranularity']).round.to_i
  })
  arg(0, 'value', 'A floating point or integer number')
end

#rule_workingDurationPercentObject



7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7679

def rule_workingDurationPercent
  pattern(%w( !number !durationUnitOrPercent ), lambda {
    if @val[1] >= 0
      # Absolute value in minutes, hours or days.
      convFactors = [ 60, # minutes
        60 * 60, # hours
        60 * 60 * @project['dailyworkinghours'] # days
      ]
      # The result will always be in number of time slots.
      (@val[0] * convFactors[@val[1]] /
       @project['scheduleGranularity']).round.to_i
    else
      # Percentage values are always returned as Float in the rage of 0.0 to
      # 1.0.
      if @val[0] < 0.0 || @val[0] > 100.0
        error('illegal_percentage',
              "Percentage values must be between 0 and 100%.",
              @sourceFileInfo[1])
      end
      @val[0] / 100.0
    end
  })
  arg(0, 'value', 'A floating point or integer number')
end

#rule_workinghoursObject



7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7704

def rule_workinghours
  pattern(%w( _workinghours !listOfDays !listOfTimes), lambda {
    if @property.nil?
      # We are changing global working hours.
      wh = @project['workinghours']
    else
      unless (wh = @property['workinghours', @scenarioIdx])
        # The property does not have it's own WorkingHours yet.
        wh = WorkingHours.new(@project['workinghours'])
      end
    end
    wh.timezone = @project['timezone']
    begin
      7.times { |i| wh.setWorkingHours(i, @val[2]) if @val[1][i] }
    rescue
      error('bad_workinghours', $!.message)
    end

    if @property
      # Make sure we actually assign something so the attribute is marked as
      # set by the user.
      begin
        @property['workinghours', @scenarioIdx] = wh
      rescue AttributeOverwrite
        # Working hours can be set multiple times.
      end
    end
  })
end

#rule_workinghoursProjectObject



7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7734

def rule_workinghoursProject
  pattern(%w( !workinghours ))
  doc('workinghours.project', <<'EOT'
Set the default working hours for all subsequent resource definitions. The
standard working hours are 9:00am - 12:00am, 1:00pm - 6:00pm, Monday to
Friday. The working hours specification limits the availability of resources
to certain time slots of week days.

These default working hours can be replaced with other working hours for
individual resources.
EOT
     )
  also(%w( dailyworkinghours workinghours.resource workinghours.shift ))
  example('Project')
end

#rule_workinghoursResourceObject



7750
7751
7752
7753
7754
7755
7756
7757
7758
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7750

def rule_workinghoursResource
  pattern(%w( !workinghours ))
  doc('workinghours.resource', <<'EOT'
Set the working hours for a specific resource. The working hours specification
limits the availability of resources to certain time slots of week days.
EOT
     )
  also(%w( workinghours.project workinghours.shift ))
end

#rule_workinghoursShiftObject



7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7760

def rule_workinghoursShift
  pattern(%w( !workinghours ))
  doc('workinghours.shift', <<'EOT'
Set the working hours for the shift. The working hours specification limits
the availability of resources or the activity on a task to certain time
slots of week days.

The shift working hours will replace the default or resource working hours for
the specified time frame when assigning the shift to a resource.

In case the shift is used for a task, resources are only assigned during the
working hours of this shift and during the working hours of the allocated
resource. Allocations only happen when both the task shift and the resource
work hours allow work to happen.
EOT
     )
  also(%w( workinghours.project workinghours.resource ))
end

#rule_yesNoObject



7779
7780
7781
7782
7783
7784
7785
7786
# File 'lib/taskjuggler/TjpSyntaxRules.rb', line 7779

def rule_yesNo
  pattern(%w( _yes ), lambda {
    true
  })
  pattern(%w( _no ), lambda {
    false
  })
end