Permalink
Browse files

Synthesize the first imaginary token to take location from the stream.

Rather than assume the token stream starts at line 1, column 0, position 1,
use the stream to inform the position.
  • Loading branch information...
1 parent e92e51b commit 1b37e253751c1efbac2c7792ab933b9175fd67e0 @dyoo committed Jan 9, 2013
Showing with 15 additions and 7 deletions.
  1. +15 −7 collects/algol60/cfg-parser.rkt
@@ -27,6 +27,8 @@
;; grammar to tokens specific to this parser. In other words, this
;; parser uses `parser' so that it doesn't have to know anything about
;; tokens.
+;;
+
(require parser-tools/yacc
@@ -758,13 +760,19 @@
(#,start tok-list
;; we simulate a token at the very beginning with zero width
;; for use with the position-generating code (*-start-pos, *-end-pos).
- (tok #f #f #f
- (position 1
- #,(if src-pos? #'1 #'#f)
- #,(if src-pos? #'0 #'#f))
- (position 1
- #,(if src-pos? #'1 #'#f)
- #,(if src-pos? #'0 #'#f)))
+ (if (null? tok-list)
+ (tok #f #f #f
+ (position 1
+ #,(if src-pos? #'1 #'#f)
+ #,(if src-pos? #'0 #'#f))
+ (position 1
+ #,(if src-pos? #'1 #'#f)
+ #,(if src-pos? #'0 #'#f)))
+ (tok (tok-name (car tok-list))
+ (tok-orig-name (car tok-list))
+ (tok-val (car tok-list))
+ (tok-start (car tok-list))
+ (tok-start (car tok-list))))
0
(length tok-list)
success-k

0 comments on commit 1b37e25

Please sign in to comment.