symbolComment method now returns array containing id -> symbolic name pair
authorvranyj1
Mon, 29 Mar 2010 11:48:57 +0000
changeset 17 0a5ab2588584
parent 16 55254a6f8404
child 18 bf9083aa33ac
symbolComment method now returns array containing id -> symbolic name pair instead of having only comment. Usable for better error reporting.
SmaCC__SmaCCGrammarCompiler.st
SmaCC__SmaCCParser.st
--- a/SmaCC__SmaCCGrammarCompiler.st	Mon Feb 15 17:57:42 2010 +0000
+++ b/SmaCC__SmaCCGrammarCompiler.st	Mon Mar 29 11:48:57 2010 +0000
@@ -306,28 +306,33 @@
 !
 
 compileSymbolComment
-        | stream |
-        stream := WriteStream on: (String new: 1000).
-        stream
-                nextPutAll: 'symbolComment';
-                cr;
-                cr;
-                tab;
-                nextPut: $";
-                cr.
-        (1 to: scannerCompiler symbols size) with: scannerCompiler symbols
-                do: 
-                        [:index :each | 
-                        stream
-                                nextPutAll: index printString;
-                                nextPutAll: '. ';
-                                nextPutAll: (each printString copyReplaceString: '"' withString: '""');
-                                cr].
-        stream nextPut: $".
-        self parserClass metaclass compile: stream contents
-                classified: #'generated-comments'
+    |stream pairs|
+
+    pairs := OrderedCollection new.
+
+    stream := WriteStream on:(String new:1000).
+    stream
+        nextPutAll:'symbolComment';
+        cr;
+        cr;
+        tab;
+        nextPutAll:'^#('; cr.
+
+    (1 to:scannerCompiler symbols size) with:scannerCompiler symbols do:
+        [:index :symbol | 
+        stream tab;tab.
+        index storeOn: stream.
+        stream tab.
+        symbol name storeOn: stream.
+        stream cr].
+
+    stream nextPutAll:')'.
+
+    self parserClass metaclass compile:stream contents
+        classified:#'generated-comments'
 
     "Modified: / 18-11-2008 / 20:05:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 28-03-2010 / 12:33:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 compileTransitionTable
--- a/SmaCC__SmaCCParser.st	Mon Feb 15 17:57:42 2010 +0000
+++ b/SmaCC__SmaCCParser.st	Mon Mar 29 11:48:57 2010 +0000
@@ -402,7 +402,7 @@
                 | errorMessage |
                 errorMessage := ((errorToken value = '') and:[scanner stream atEnd])
                                     ifTrue:['Unexpected end of file']
-                                    ifFalse:[aString , ': ' , errorToken value].
+                                    ifFalse:[aString].
                 SmaCCParserError raiseSignal: errorMessage with: self
             ] ifNil:[
                 SmaCCParserError raiseSignal: aString with:self
@@ -412,6 +412,7 @@
         ]
 
     "Modified: / 05-01-2007 / 13:04:48 / janfrog"
+    "Modified: / 29-03-2010 / 13:15:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 willShift: potentialStateStack