diff options
Diffstat (limited to 'gcc/m2/gm2-compiler/P3Build.bnf')
-rw-r--r-- | gcc/m2/gm2-compiler/P3Build.bnf | 99 |
1 files changed, 68 insertions, 31 deletions
diff --git a/gcc/m2/gm2-compiler/P3Build.bnf b/gcc/m2/gm2-compiler/P3Build.bnf index 4f6ffb7..0033d33 100644 --- a/gcc/m2/gm2-compiler/P3Build.bnf +++ b/gcc/m2/gm2-compiler/P3Build.bnf @@ -166,14 +166,14 @@ FROM SymbolTable IMPORT MakeGnuAsm, PutGnuAsmVolatile, PutGnuAsm, PutGnuAsmInput MakeRegInterface, PutRegInterface, IsRegInterface, IsGnuAsmVolatile, IsGnuAsm, - GetCurrentModule, + GetCurrentModule, IsInnerModule, GetSymName, GetType, SkipType, NulSym, StartScope, EndScope, PutIncluded, IsVarParam, IsProcedure, IsDefImp, IsModule, IsProcType, IsRecord, - RequestSym, IsExported, + RequestSym, IsExported, IsImported, GetSym, GetLocalSym ; FROM M2Batch IMPORT IsModuleKnown ; @@ -468,6 +468,69 @@ BEGIN Expect(realtok, stopset0, stopset1, stopset2) END Real ; + +(* + PushTFQualident - push the result of the Qualident + to the stack. It checks to see if init + is a procedure or proc type and if so + it does not push the return type. +*) + +PROCEDURE PushTFQualident (tok, tokstart: CARDINAL; + init: CARDINAL) ; +BEGIN + IF tok#tokstart + THEN + tok := MakeVirtualTok (tokstart, tokstart, tok) + END ; + IF IsProcedure (init) OR IsProcType (init) OR IsModule (init) OR IsDefImp (init) + THEN + PushTtok (init, tok) ; + Annotate ("%1s(%1d)||qualident procedure/proctype") ; + ELSE + Annotate ("%1s(%1d)|%1s(%1d)||qualident|type") ; + PushTFtok (init, GetType (init), tok) ; + END +END PushTFQualident ; + + +(* + CheckModuleQualident - check to see if the beginning ident of the qualident is an + imported module. +*) + +PROCEDURE CheckModuleQualident (stopset0: SetOfStop0; + stopset1: SetOfStop1; + stopset2: SetOfStop2) ; +VAR + name : Name ; + init, + nextLevel, + tok, tokstart: CARDINAL ; +BEGIN + PopTtok (name, tokstart) ; + tok := tokstart ; + init := RequestSym (tok, name) ; + IF (IsImported (GetCurrentModule (), init) AND IsDefImp (init)) OR + IsModule (init) + THEN + WHILE IsDefImp (init) OR IsModule (init) DO + Expect (periodtok, stopset0, stopset1, stopset2 + SetOfStop2{identtok}) ; + StartScope (init) ; + Ident (stopset0, stopset1, stopset2) ; + PopTtok (name, tok) ; + nextLevel := RequestSym (tok, name) ; + EndScope ; + CheckCanBeImported (init, nextLevel) ; + init := nextLevel + END ; + PushTFQualident (tok, tokstart, init) ; + PutIncluded (init) + ELSE + PushTFQualident (tok, tokstart, init) + END +END CheckModuleQualident ; + % module P3Build end BEGIN BlockState := InitState () @@ -643,37 +706,11 @@ Number := Integer | Real =: -- IsAutoPushOff then we just consume tokens. -- -Qualident := % VAR name : Name ; - init, ip1, - tokstart, tok : CARDINAL ; % - Ident +Qualident := Ident % IF IsAutoPushOn() THEN - PopTtok(name, tokstart) ; - tok := tokstart ; - init := RequestSym (tok, name) ; - WHILE IsDefImp (init) OR IsModule (init) DO - Expect (periodtok, stopset0, stopset1, stopset2 + SetOfStop2{identtok}) ; - StartScope (init) ; - Ident (stopset0, stopset1, stopset2) ; - PopTtok (name, tok) ; - ip1 := RequestSym (tok, name) ; - PutIncluded(ip1) ; - EndScope ; - CheckCanBeImported(init, ip1) ; - init := ip1 - END ; - IF tok#tokstart - THEN - tok := MakeVirtualTok (tokstart, tokstart, tok) - END ; - IF IsProcedure(init) OR IsProcType(init) - THEN - PushTtok(init, tok) - ELSE - PushTFtok(init, GetType(init), tok) ; - END - ELSE % + CheckModuleQualident (stopset0, stopset1, stopset2) + ELSE (* just parse qualident *) % { "." Ident } % END % =: |