Skip to content

Commit

Permalink
stinst: Be able to parse class pragmas with multiple keywords.
Browse files Browse the repository at this point in the history
2012-10-02  Holger Freyther  <holger@freyther.de>

	* tests/stcompiler.st: Add testcase for pragma parsing.
	* tests/stcompiler.ok: Update the test result.

2012-10-02  Holger Freyther  <holger@freyther.de>

	* GSTParser.st: Change GSTFileInParser>>#parseClassTag to parse
	more complicated pragmas.
  • Loading branch information
zecke authored and bonzini committed Oct 8, 2012
1 parent 983e5e7 commit fa264ab
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2012-10-02 Holger Freyther <holger@freyther.de>

* tests/stcompiler.st: Add testcase for pragma parsing.
* tests/stcompiler.ok: Update the test result.

2012-09-29 Holger Freyther <holger@freyther.de>

* scripts/Convert.st: Collect all rewrite expressions and parse
Expand Down
5 changes: 5 additions & 0 deletions packages/stinst/parser/ChangeLog
@@ -1,3 +1,8 @@
2012-10-02 Holger Freyther <holger@freyther.de>

* GSTParser.st: Change GSTFileInParser>>#parseClassTag to parse
more complicated pragmas.

2012-09-29 Holger Freyther <holger@freyther.de>

* RBParser.st: Add RBScanner>>#digitValue:.
Expand Down
19 changes: 13 additions & 6 deletions packages/stinst/parser/GSTParser.st
Expand Up @@ -237,21 +237,28 @@ STInST.STFileInParser subclass: GSTFileInParser [
]

parseClassTag [
| selector argument stmt |
| selectors arguments stmt |

self skipExpectedToken: #<.

(currentToken isKeyword)
ifTrue: [selector := currentToken value asSymbol. self step]
ifFalse: [self parserError: 'expected keyword'].

argument := self parsePrimitiveObject.

selectors := OrderedCollection new.
arguments := OrderedCollection new.

"Consume all keywords and literals of the pragma"
[currentToken isKeyword] whileTrue: [
selectors add: currentToken. self step.
arguments add: self parsePrimitiveObject.
].

self skipExpectedToken: #>.

stmt := RBMessageNode
receiver: taggee
selector: selector
arguments: { argument }.
selectorParts: selectors
arguments: arguments.
self evaluateStatement: stmt.
]

Expand Down
7 changes: 7 additions & 0 deletions tests/stcompiler.st
Expand Up @@ -104,6 +104,13 @@ literalValueFoo12345
Eval [
| classes |

"Attempt to parse a pragma with multiple parameters"
classes := STInST.STClassLoader new
parseSmalltalkStream: 'Object subclass: Bla [
<pragma: 1 withParam: 3> ]' readStream
with: STInST.GSTFileInParser.

"Check if the proxy has a proper behavior"
classes := STInST.STClassLoader new
parseSmalltalkStream: 'Object subclass: Foo []' readStream
with: STInST.GSTFileInParser.
Expand Down

0 comments on commit fa264ab

Please sign in to comment.