OK, although that doesn't really address my question because you started with NONE and went to ALL, I see from your example that I could accomplish what I would be looking for with a slice.
Your example does bring up another question though - what about growths with multiple GROWTH_PRINTs? ... There are 4 growth prints which vary only in their args. Can I change the color (args 2-4 inclusive 0-based) of the 2nd GROWTH_PRINT without touching the others?
I'm not sure I understand what you mean, then. Can you provide some sort of pseudocode example of what you would expect to be able to do?
As for multiple GROWTH_PRINTs, they could be handled like this:
>>> pomegranate = df.getobj('PLANT:POMEGRANATE')
>>> print pomegranate
[PLANT:POMEGRANATE]
>>> growths = pomegranate.allprop('GROWTH_PRINT')
>>> print growths
[
[GROWTH_PRINT:0:6:2:0:0:0:209999:1],
[GROWTH_PRINT:0:6:6:0:1:210000:239999:1], autumn color
[GROWTH_PRINT:0:6:4:0:1:240000:269999:1],
[GROWTH_PRINT:0:6:4:0:0:270000:300000:1],
[GROWTH_PRINT:5:5:4:0:1:60000:119999:2],
[GROWTH_PRINT:'%':'%':4:0:1:120000:200000:3]]
>>> growths[1].args[2] = 'some value'
>>> growths[1].args[3] = 'some other value'
>>> growths[1].args[4] = 'some other value again'
>>> print growths
[
[GROWTH_PRINT:0:6:2:0:0:0:209999:1],
[GROWTH_PRINT:0:6:some value:some other value:some other value a
gain:210000:239999:1], autumn color
[GROWTH_PRINT:0:6:4:0:1:240000:269999:1],
[GROWTH_PRINT:0:6:4:0:0:270000:300000:1],
[GROWTH_PRINT:5:5:4:0:1:60000:119999:2],
[GROWTH_PRINT:'%':'%':4:0:1:120000:200000:3]]
It might be helpful to see PyDwarf's querying functionality as a bunch of methods that look for tokens in a linked list, starting with some particular token, that match some particular conditions, and ceasing to accumulate matching tokens on some condition. Because that's exactly what it is. All of the querying methods are built on top of a generalized query method that takes filter objects and an iterable collection of tokens as arguments. For example, the method
allprop as used in the above code starts from the current token and returns everything with a value of 'GROWTH_PRINT' until it encounters the next token with a value of 'PLANT'. And each of the token objects in the list returned can be operated on in any way from adding more tokens before or after, removing the token, or accessing/modifying its attributes e.g. its arguments.
If you navigate a terminal to your PyDwarf directory, try entering
python and entering the same commands as above. (Don't forget to
import raws and
df = raws.dir(path="..."). You will need to change the path in raws.dir(path="...") to refer to actual raws on your machine.) Screw around with them as you see fit, and the workings should become more apparent.
Well, if that's the definition then that's the definition, but it's an extraordinarily unhelpful one for performing lexical analysis.
Given the raws snippet [CREATURE:DWARF] a lexical scanner would break it down into these elements: '[', 'CREATURE', ':', 'DWARF', ']'. These are formally called
lexemes, but are typically referred to as
tokens in the context of lexical scanners. In no context that I know of would tokens conventionally refer to 'CREATURE' and 'DWARF' only. The term I've most frequently seen to refer to the tags/tokens in raws is
token, for example
this wiki page. The first item in the list delimited by colons represents the purpose of the token, and
value seemed to me a reasonable term to use. The others elaborate on the first in much the same way as
arguments passed to some procedure.