=============== Summary ===============
Change Set: pragmaParsers-subclasses Date: 28 April 2024 Author: Christoph Thiede
Do not ignore <pragmaParser> methods in subclasses of Parser or SHParserST80.
=============== Diff ===============
Behavior>>lookupSelector:upTo: {accessing method dictionary} · ct 4/28/2024 19:59 + lookupSelector: selector upTo: aSuperclass + "Look up the given selector in my methodDictionary. + Return the corresponding method if found. + Otherwise chase my superclass chain and try again. + Do not search beyond aSuperclass. + Return nil if no method is found." + | lookupClass | + lookupClass := self. + [lookupClass == nil] + whileFalse: + [(lookupClass includesSelector: selector) + ifTrue: [^ lookupClass compiledMethodAt: selector]. + lookupClass == aSuperclass ifTrue: [^ nil]. + lookupClass := lookupClass superclass]. + ^ nil
Parser>>pragmaStatement {pragmas} · ct 4/28/2024 21:55 (changed) pragmaStatement "Parse a pragma statement. The leading '<' has already been consumed. The 'here' token is the first one in the pragma. Use that token to dispatch to a custom pragma-parsing method if one can be found with a selector that matches it. Note that custom pragma parsers need to fulfill two requirements: - method selector must match the current token as simple getter, e.g., <apicall: ...> matches #apicall or <primitive: ...> matches #primitive - method must have pragma <pragmaParser> to be called." "0) Early exit" (hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ]) ifFalse: [ ^ self expected: 'pragma declaration' ]. "1) Do not consider one-word pragmas such as <primitive> and <foobar>. Only keyword pragmas." "2) Avoid interning new symbols for made-up pragmas such as #my for <my: 1 pragma: 2>." (Symbol lookup: (here last == $: ifTrue: [here allButLast] ifFalse: [here])) ifNotNil: [:parserSelector | - Parser methodDict at: parserSelector ifPresent: [:parserMethod | + (self class lookupSelector: parserSelector upTo: Parser) ifNotNil: [:parserMethod | "3) Only call methods that claim to be a custom pragma parser via <pragmaParser>." (parserMethod hasPragma: #pragmaParser) ifTrue: [^ self executeMethod: parserMethod]]]. "X) No custom pragma parser found. Use the default one." ^ self pragmaStatementKeywords
SHParserST80>>parsePragmaStatement {parse pragma} · ct 4/28/2024 20:39 (changed) parsePragmaStatement "Parse a pragma statement. The leading '<' has already been consumed. The currentToken is the first one in the pragma. Use that token to dispatch to a custom pragma-parsing method if one can be found with a selector that matches it. Note that custom pragma parsers need to fulfill two requirements: - method selector must match the current token as simple getter, e.g., <apicall: ...> matches #apicall or <primitive: ...> matches #primitive - method must have pragma <pragmaParser> to be called."
"1) Do not consider one-word pragmas such as <primitive> and <foobar>. Only keyword pragmas." currentToken last == $: ifTrue: [ "2) Avoid interning new symbols for made-up pragmas such as #my for <my: 1 pragma: 2>." (Symbol lookup: currentToken allButLast) ifNotNil: [:parserSelector | - SHParserST80 methodDict at: parserSelector ifPresent: [:parserMethod | + (self class lookupSelector: parserSelector upTo: SHParserST80) ifNotNil: [:parserMethod | "3) Only call methods that claim to be a custom pragma parser via <pragmaParser>." (parserMethod hasPragma: #pragmaParser) ifTrue: [^ self executeMethod: parserMethod]]]].
"X) No custom pragma parser found. Use the default one." ^ self parsePragmaDefault
--- Sent from Squeak Inbox Talk ["pragmaParsers-subclasses.1.cs"]
squeak-dev@lists.squeakfoundation.org