[PATCH] stinst: Be able to parse class pragmas with multiple keywords.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] stinst: Be able to parse class pragmas with multiple keywords.

Holger Freyther
From: Holger Hans Peter Freyther <[hidden email]>

2012-10-02  Holger Freyther  <[hidden email]>

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

2012-10-02  Holger Freyther  <[hidden email]>

        * GSTParser.st: Change GSTFileInParser>>#parseClassTag to parse
        more complicated pragmas.
---
 ChangeLog                           |    5 +++++
 packages/stinst/parser/ChangeLog    |    5 +++++
 packages/stinst/parser/GSTParser.st |   19 +++++++++++++------
 tests/stcompiler.st                 |    7 +++++++
 4 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c08ade..91c384e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-02  Holger Freyther  <[hidden email]>
+
+ * tests/stcompiler.st: Add testcase for pragma parsing.
+ * tests/stcompiler.ok: Update the test result.
+
 2012-09-29  Holger Freyther  <[hidden email]>
 
  * scripts/Convert.st: Collect all rewrite expressions and parse
diff --git a/packages/stinst/parser/ChangeLog b/packages/stinst/parser/ChangeLog
index 31bb50c..58affee 100644
--- a/packages/stinst/parser/ChangeLog
+++ b/packages/stinst/parser/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-02  Holger Freyther  <[hidden email]>
+
+ * GSTParser.st: Change GSTFileInParser>>#parseClassTag to parse
+ more complicated pragmas.
+
 2012-09-29  Holger Freyther  <[hidden email]>
 
  * RBParser.st: Add RBScanner>>#digitValue:.
diff --git a/packages/stinst/parser/GSTParser.st b/packages/stinst/parser/GSTParser.st
index c84410a..9e1d0ef 100644
--- a/packages/stinst/parser/GSTParser.st
+++ b/packages/stinst/parser/GSTParser.st
@@ -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.
     ]
     
diff --git a/tests/stcompiler.st b/tests/stcompiler.st
index 084f5f9..8f67250 100644
--- a/tests/stcompiler.st
+++ b/tests/stcompiler.st
@@ -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.
--
1.7.10.4


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] stinst: Be able to parse class pragmas with multiple keywords.

Paolo Bonzini-2
Il 02/10/2012 15:59, Holger Hans Peter Freyther ha scritto:

> From: Holger Hans Peter Freyther <[hidden email]>
>
> 2012-10-02  Holger Freyther  <[hidden email]>
>
> * tests/stcompiler.st: Add testcase for pragma parsing.
> * tests/stcompiler.ok: Update the test result.
>
> 2012-10-02  Holger Freyther  <[hidden email]>
>
> * GSTParser.st: Change GSTFileInParser>>#parseClassTag to parse
> more complicated pragmas.
> ---
>  ChangeLog                           |    5 +++++
>  packages/stinst/parser/ChangeLog    |    5 +++++
>  packages/stinst/parser/GSTParser.st |   19 +++++++++++++------
>  tests/stcompiler.st                 |    7 +++++++
>  4 files changed, 30 insertions(+), 6 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 8c08ade..91c384e 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,8 @@
> +2012-10-02  Holger Freyther  <[hidden email]>
> +
> + * tests/stcompiler.st: Add testcase for pragma parsing.
> + * tests/stcompiler.ok: Update the test result.
> +
>  2012-09-29  Holger Freyther  <[hidden email]>
>  
>   * scripts/Convert.st: Collect all rewrite expressions and parse
> diff --git a/packages/stinst/parser/ChangeLog b/packages/stinst/parser/ChangeLog
> index 31bb50c..58affee 100644
> --- a/packages/stinst/parser/ChangeLog
> +++ b/packages/stinst/parser/ChangeLog
> @@ -1,3 +1,8 @@
> +2012-10-02  Holger Freyther  <[hidden email]>
> +
> + * GSTParser.st: Change GSTFileInParser>>#parseClassTag to parse
> + more complicated pragmas.
> +
>  2012-09-29  Holger Freyther  <[hidden email]>
>  
>   * RBParser.st: Add RBScanner>>#digitValue:.
> diff --git a/packages/stinst/parser/GSTParser.st b/packages/stinst/parser/GSTParser.st
> index c84410a..9e1d0ef 100644
> --- a/packages/stinst/parser/GSTParser.st
> +++ b/packages/stinst/parser/GSTParser.st
> @@ -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.
>      ]
>      
> diff --git a/tests/stcompiler.st b/tests/stcompiler.st
> index 084f5f9..8f67250 100644
> --- a/tests/stcompiler.st
> +++ b/tests/stcompiler.st
> @@ -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.
>

Applied.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk