more lineNumber info
authorClaus Gittinger <cg@exept.de>
Mon, 21 Oct 1996 16:01:10 +0200
changeset 382 49aeeb0746ba
parent 381 f1366b7aa598
child 383 fc4b30e5e511
more lineNumber info
Parser.st
--- a/Parser.st	Mon Oct 21 16:00:31 1996 +0200
+++ b/Parser.st	Mon Oct 21 16:01:10 1996 +0200
@@ -2064,36 +2064,42 @@
 
     lno := tokenLineNr.
     (tokenType == $| ) ifTrue:[
-	self nextToken.
-	[tokenType == $|] whileFalse:[
-	    (tokenType == #Identifier) ifFalse:[
-		^ self identifierExpectedIn:'block-var declaration'
-	    ].
-	    var := Variable name:tokenName.
-	    vars isNil ifTrue:[
-		vars := Array with:var.
-		names := Array with:tokenName
-	    ] ifFalse:[
-		(names includes:tokenName) ifTrue:[
-		    self parseError:'redefinition of ''' , tokenName , ''' in local variables'
-			   position:tokenPosition to:tokenPosition + tokenName size -1.
-		] ifFalse:[
-		    vars := vars copyWith:var.
-		    names := names copyWith:tokenName
-		]
-	    ].
-	    self nextToken.
-	].
-	self nextToken
+        self nextToken.
+        [tokenType == $|] whileFalse:[
+            (tokenType == #Identifier) ifFalse:[
+                ^ self identifierExpectedIn:'block-var declaration'
+            ].
+            var := Variable name:tokenName.
+            vars isNil ifTrue:[
+                vars := Array with:var.
+                names := Array with:tokenName
+            ] ifFalse:[
+                (names includes:tokenName) ifTrue:[
+                    self parseError:'redefinition of ''' , tokenName , ''' in local variables'
+                           position:tokenPosition to:tokenPosition + tokenName size -1.
+                ] ifFalse:[
+                    vars := vars copyWith:var.
+                    names := names copyWith:tokenName
+                ]
+            ].
+            self nextToken.
+        ].
+        self nextToken
     ].
+
     node := BlockNode arguments:args home:currentBlock variables:vars.
     node lineNumber:lno.
     currentBlock := node.
     stats := self blockStatementList.
+    lineNumberInfo == #full ifTrue:[
+        node endLineNumber:tokenLineNr
+    ].
     node statements:stats.
     currentBlock := node home.
     (stats == #Error) ifTrue:[^ #Error].
     ^ node
+
+    "Modified: 21.10.1996 / 14:48:56 / cg"
 !
 
 blockExpression
@@ -2747,7 +2753,7 @@
 primary
     "parse a primary-expression; return a node-tree, nil or #Error"
 
-    |val var expr pos name t cls nameSpace nameSpaceGlobal globlName|
+    |val var expr pos name t cls nameSpace nameSpaceGlobal globlName lnr node|
 
     pos := tokenPosition.
     (tokenType == #Self) ifTrue:[
@@ -2917,10 +2923,13 @@
             ].
         ].
 
+        lnr := tokenLineNr.
         self nextToken.
         expr := self expression.
         (errorFlag or:[expr == #Error]) ifTrue:[^ #Error].
-        ^ AssignmentNode variable:var expression:expr
+        node := AssignmentNode variable:var expression:expr.
+        (lineNumberInfo == #full) ifTrue:[node lineNr:lnr].
+        ^ node
     ].
 
     ((tokenType == #Integer) 
@@ -3063,52 +3072,56 @@
     ^ #Error
 
     "Created: 13.9.1995 / 12:50:50 / claus"
-    "Modified: 15.10.1996 / 12:24:02 / cg"
+    "Modified: 21.10.1996 / 12:33:03 / cg"
 !
 
 statement
     "parse a statement; return a node-tree or #Error.
 
      statement ::= '^' expression
-		   | PRIMITIVECODE
-		   | expression
+                   | PRIMITIVECODE
+                   | expression
     "
 
-    |expr node|
+    |expr node lnr|
 
     (tokenType == $^) ifTrue:[
-	self nextToken.
-	expr := self expression.
-	(expr == #Error) ifTrue:[^ #Error].
-	node := ReturnNode expression:expr.
-	node home:self blockHome:currentBlock.
-	^ node
+        lnr := tokenLineNr.
+        self nextToken.
+        expr := self expression.
+        (expr == #Error) ifTrue:[^ #Error].
+        node := ReturnNode expression:expr.
+        node home:self blockHome:currentBlock.
+        (lineNumberInfo == #full) ifTrue:[node lineNr:lnr].
+        ^ node
     ].
     (tokenType == #Primitive) ifTrue:[
-	self nextToken.
-	node := PrimitiveNode code:tokenValue.
-	node isOptional ifFalse:[
-	    hasNonOptionalPrimitiveCode := true
-	].
-	hasPrimitiveCode := true.
-	^ node
+        self nextToken.
+        node := PrimitiveNode code:tokenValue.
+        node isOptional ifFalse:[
+            hasNonOptionalPrimitiveCode := true
+        ].
+        hasPrimitiveCode := true.
+        ^ node
     ].
     (tokenType == #EOF) ifTrue:[
-	self syntaxError:'period after last statement'.
-	^ #Error
+        self syntaxError:'period after last statement'.
+        ^ #Error
     ].
     expr := self expression.
     (expr == #Error) ifTrue:[^ #Error].
 "
     classToCompileFor notNil ifTrue:[
-	currentBlock isNil ifTrue:[
-	    expr isPrimary ifTrue:[
-		self warning:'useless computation - missing ^ ?'
-	    ]
-	]
+        currentBlock isNil ifTrue:[
+            expr isPrimary ifTrue:[
+                self warning:'useless computation - missing ^ ?'
+            ]
+        ]
     ].
 "
     ^ StatementNode expression:expr
+
+    "Modified: 21.10.1996 / 12:33:49 / cg"
 !
 
 statementList
@@ -3625,6 +3638,6 @@
 !Parser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.95 1996-10-21 12:12:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.96 1996-10-21 14:01:10 cg Exp $'
 ! !
 Parser initialize!