- implement scanner token stream via channel
- change test_scanner to scan using both methods
- add -pscan flag to Go front-end to choose between conventional
synchronous or parallel asynchronous scanning
R=r
OCL=13937
CL=13937
diff --git a/usr/gri/gosrc/parser.go b/usr/gri/gosrc/parser.go
index 3433b63..2e2346e 100644
--- a/usr/gri/gosrc/parser.go
+++ b/usr/gri/gosrc/parser.go
@@ -19,6 +19,7 @@
semantic_checks bool;
verbose, indent int;
S *Scanner.Scanner;
+ C *chan *Scanner.Token;
// Token
tok int; // one token look-ahead
@@ -62,7 +63,12 @@
func (P *Parser) Next() {
- P.tok, P.pos, P.val = P.S.Scan();
+ if P.C == nil {
+ P.tok, P.pos, P.val = P.S.Scan();
+ } else {
+ t := <- P.C;
+ P.tok, P.pos, P.val = t.tok, t.pos, t.val;
+ }
if P.verbose > 1 {
P.PrintIndent();
print "[", P.pos, "] ", Scanner.TokenName(P.tok), "\n";
@@ -70,12 +76,13 @@
}
-func (P *Parser) Open(comp *Globals.Compilation, S *Scanner.Scanner) {
+func (P *Parser) Open(comp *Globals.Compilation, S *Scanner.Scanner, C *chan *Scanner.Token) {
P.comp = comp;
P.semantic_checks = comp.flags.semantic_checks;
P.verbose = comp.flags.verbose;
P.indent = 0;
P.S = S;
+ P.C = C;
P.Next();
P.level = 0;
P.top_scope = Universe.scope;