# Copyright 2005 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ ? def := ; null --- Terms ? def makeAstroTag := # value: ? def tag := makeAstroTag(44, "foo", nullOk) # value: ? tag == makeAstroTag(44, "foo", nullOk) # value: true ? tag != makeAstroTag(null, "foo", nullOk) # value: true ? [tag.getOptTagCode(), tag.getTagName(), tag.getDataGuard()] # value: [44, "foo", nullOk] XXX EoJ tags respond to isTagForData/1, op__cmp/1 ? def makeTerm := # value: ? makeTerm(tag, 99, null, []) # problem: must be null ? def term := makeTerm(tag, null, null, []) # value: term`foo` ? def nestedTerm := makeTerm(makeAstroTag(null, "bar", nullOk), null, null, [term]) # value: term`bar(foo)` Term guard ? def Term := makeTerm.asType() # value: Term ? Term == # value: true check for BaseGuard ? Term[] # value: List[Term] Basic accept/reject ? "foo" :Term # problem: not a Term: "foo" ? term :Term # value: term`foo` Terms can hold arbitrary data, but are not 'standard' Terms ? def termBadData := makeTerm(makeAstroTag(44, "bar", any), def x {}, null, []) # value: term`bar` ? termBadData :Term # problem: doesn't match any of [nullOk, int, float64, char, Twine] Terms can hold arbitrary children, but ditto. ? def termNonTree := makeTerm(tag, null, null, ["bar"]) # value: term`foo("bar")` ? termNonTree :Term # problem: not a Term: "bar" ? def LooseTerm := Term[any, any, any] # value: Term[any, any, any] ? termNonTree :LooseTerm # value: term`foo("bar")` ? termBadData :LooseTerm # value: term`bar` XXX test tag restrictions ? term.getTerms() # value: [term`foo`] --- Lexer ? def makeTermLexer := ; null ? def lex(twine) :any { return makeTermLexer(false)(twine.asStream()).readAll() }; null ? lex("foo") # value: [["Tag", [["Ident", "foo"]]]] ? lex("(,)[{:]}") # value: [["("], [","], [")"], ["["], ["{"], [":"], ["]"], ["}"]] ? lex("foo(bar)") # value: [["Tag", [["Ident", "foo"]]], ["("], ["Tag", [["Ident", "bar"]]], [")"]] ? lex(".foo. .bar.baz") # value: [["Tag", [["Ident", ".foo."]]], ["Tag", [["Ident", ".bar.baz"]]]] ? lex("${9} @{10} ") # value: [["Quasi$", 9], ["Quasi@", 10]] ? lex("0 1 2 107 -1 3 000") # value: [["Integer", 0], ["Integer", 1], ["Integer", 2], ["Integer", 107], ["Integer", -1], ["Integer", 3], ["Integer", 0]] XXX errors to be changed ? lex("+3") # problem: unexpected term token: +3 XXX token types: integer, float, char, string, tag, punct, chars XXX consequence of loose ::, or malformed tags in general XXX consequence of non-token characters ... temporarily? continued in term/parse.updoc