Atlas Autocode Compiler for KDF9 - Version K - Syntax
-----------------------------------------------------

Version K was the (first) ISO code version and was produced sometime in
the middle of 1966.

In the following
the C statements introduce the terminal symbols,
the D statements introduce the non-terminal symbols,
the P statements define the syntax, and
the E statement marks the end of the syntax.

A large part of the syntax is concerned with the definition of KDF9
machine code (user code) which could be placed in-line.

Perhaps the most important semantic difference between Atlas Autocode
and (later versions of) IMP was the wordlength.

In Atlas Autocde on KDF9, both integers and reals were 48 bit.

IMP was designed to have 32 bit integers to imitate System 4.

Harry Whitfield (26/02/2002).


C"+"
C"-"
C"*"
C"/"
C"^"
C"("
C")"
C","
C"?"
C"!" 
C":"
C"=" 
C">="
C">"
C"#" 
C"<" 
C"<="
C"->"
C"%IF"
C"%UNLESS"
C"%INTEGER"
C"%REAL"
C"%FN"
C"%MAP"
C"%NAME"
C"%ROUTINE"
C"%ARRAY"
C"%AND"
C"%OR"
C"%CAPTION"
C"%RESULT="
C"%RETURN"
C"%STOP"
C"%THEN"
C"%CYCLE" 
C"%REPEAT"
C"%SPEC"
C"%BEGIN"
C"%COMMENT"
C"%END"
C"%PROGRAM"
C"%IGNORE"
C"%SWITCH"
C"%UPPER"
C"%DELIMITERS"
C"%NORMAL"
C"%CASE"
C"%COMPILE"
C"%QUERIES"
C"%ADDR"
C"%DEFINE"
C"%R"
C"%PERM"
C"T"
C"%MCODE"
C"%OF"
C"%STRINGS"
C"%FAULT"
C"%MONITOR"

C"@"
C"J"
C"SET"
C"JS"
C"EXIT"
C"M"
C"SH"
C"Q"
C"TOQ"
C"C"
C"I"
C"IM"
C"CM"
C"CI"
C"NC"
C"DC"
C"LINK"
C"HF"
C"F"
C"H"
C"ROUND"
C"D"
C"FLOAT"
C"ERASE"
C"REV"
C"ZERO"
C"DUP"
C"DF"
C"NEG"
C"ABS"
C"MAX"
C"SIGN"
C"CAB"
C"FRB"
C"STAND"
C"/R"
C"/I"
C"/X"
C"=TR"
C"BITS"
C"DUMMY"
C"PERM"
C"TOP"
C"OR"
C"VR"
C"NEV"
C"NOT"
C"FIX"
C"STR"
C"CONT"
C"AND"
C"OUT"
C"S"
C"NZ"
C"Z"
C"V"
C"NV"
C"EN"
C"NEN"
C"EJ"
C"NEJ"
C"TR"
C"NTR"
C"QHN"
C"QH"
C"QN"
C"HN"
C"N"
C"A"
C"AD"
C"L"
C"LD"
C"AC"
C"ADC"
C"LC"
C"LDC"
C"CC"
C"RC"
C"RI"
C"RM"
C"+Q"
C"+C"
C"+I"
C"+M"
C"P"
C"B"
C"O"
C"E"
C"TLOQ"
C"INTQ"
C"PARQ"
C"BUSYQ"
C"MANUALQ"
C"CTQ"
C"CLOQ"
C"ADVCA"


D[NAME]
D[CONST]
D[N]
D[S]
D[TEXT]
D[CAPTIONTEXT]
D[OCTAL]
D[SETMARKER1]
D[SETMARKER2]
D[+']
D[OPERAND]
D[APP]
D[OP]
D[QUERY']
D[,']
D[%IU]
D[%REAL']
D[TYPE]
D[TYPE']
D[RESTOFARRAYLIST]
D[RESTOFFP-LIST]
D[RESTOFEXPR-LIST]
D[RESTOFUI]
D[RESTOFNAMELIST]
D[%SPEC']
D[RESTOFSWITCHLIST]
D[RESTOFPP-LIST]
D[RESTOFEXPR]
D[RESTOFCOND]
D[RESTOFAND-C]
D[RESTOFOR-C]
D[RESTOFSC]
D[RT]
D[FPP]
D[FP-DELIMITER]
D[SC]
D[COMP]
D[RESTOFSS1]
D[RESTOFN-LIST]
D[RESTOFFAULTLIST]
D[UCI]
D[J-INSTR]
D[MS-INSTR]
D[SH-INSTR]
D[QS-INSTR]
D[+]
D[=']
D[P']
D[IOM]
D[ATOF]
D[E-INSTR]

D[UI]
D[SS]


P[+']=
"+","-",0;
P[OPERAND]=
[NAME][APP],[CONST],"("[+'][OPERAND][RESTOFEXPR]")","!"[+'][OPERAND][RESTOFEXPR]"!";
P[RESTOFEXPR]=
[OP][OPERAND][RESTOFEXPR],0;
P[APP]=
"("[+'][OPERAND][RESTOFEXPR][RESTOFEXPR-LIST]")",0;
P[RESTOFEXPR-LIST]=
","[+'][OPERAND][RESTOFEXPR][RESTOFEXPR-LIST],0;
P[OP]=
"+","-","*","/","^",0;
P[QUERY']=
"?",0;
P[,']=
",",0;
P[%IU]=
"%IF","%UNLESS";
P[%REAL']=
"%REAL",0;
P[TYPE]=
"%INTEGER","%REAL";
P[TYPE']=
"%INTEGER","%REAL",0;
P[RT]=
"%ROUTINE","%REAL""%FN","%INTEGER""%FN","%REAL""%MAP","%INTEGER""%MAP";
P[FP-DELIMITER]=
[RT],"%INTEGER""%ARRAY""%NAME","%INTEGER""%NAME","%INTEGER",
[%REAL']"%ARRAY""%NAME","%REAL""%NAME","%REAL","%ADDR";
P[FPP]=
"("[FP-DELIMITER][NAME][RESTOFNAMELIST][RESTOFFP-LIST]")",0;
P[RESTOFFP-LIST]=
[,'][FP-DELIMITER][NAME]RESTOFNAMELIST][RESTOFFP-LIST],0;
P[RESTOFNAMELIST]=
","[NAME][RESTOFNAMELIST],0;
P[SC]=
[+'][OPERAND][RESTOFEXPR][COMP][+'][OPERAND][RESTOFEXPR][RESTOFSC],"("[SC][RESTOFCOND]")";
P[RESTOFSC]=
[COMP][+'][OPERAND][RESTOFEXPR],0;
P[RESTOFCOND]=
"%AND"[SC][RESTOFAND-C],"%OR"[SC][RESTOFOR-C],0;
P[RESTOFAND-C]=
"%AND"[SC][RESTOFAND-C],0;
P[RESTOFOR-C]=
"%OR"[SC][RESTOFOR-C],0;
P[RESTOFUI]=
"="[+'][OPERAND][RESTOFEXPR][QUERY'],0;
P[%SPEC']=
"%SPEC",0;
P[RESTOFFPP-LIST]=
","[+'][OPERAND][RESTOFEXPR]":"[+'][OPERAND][RESTOFEXPR][RESTOFFPP-LIST],0;
P[RESTOFARRAYLIST]=
","[NAME][RESTOFNAMELIST]"("[+'][OPERAND][RESTOFEXPR]
":"
[+'][OPERAND][RESTOFEXPR][RESTOFFPP-LIST]")"[RESTOFARRAYLIST],0;
P[RESTOFSWITCHLIST]=
","[NAME][RESTOFNAMELIST]"("[+'][CONST]":"[+'][CONST]")"[RESTOFSWITCHLIST],0;
P[COMP]=
"=",">=",">","#","<=","<";
P[RESTOFSS1]=
[S],[%IU][SC][RESTOFCOND][S];
P[RESTOFFN-LIST]=
","[N][RESTOFFN-LIST],0;
P[RESTOFFAULTLIST]=
","[N][RESTOFFN-LIST]"->"[N][RESTOFFAULTLIST],0;


P[UCI]=
"*""@"[NAME][APP],"*"[='][NAME][APP],"J"[N][P'][J-INSTR],
"SET""B"[OCTAL]."SET"[N]"P"":","JS"[N][P'],"EXIT"[N],
[=']"M"[N]"M"[N][MS-INSTR],"SH"[SH-INSTR],"="[QS-INSTR],
"Q"[N]"TOQ"[N],"C"[N]"TOQ"[N],"I"[N]"TOQ"[N],"M"[N]"TOQ"[N],
"IM"[N]"TOQ"[N],"CM"[N]"TOQ"[N],"CI"[N]"TOQ"[N]."I"[N]"="[+'][N],
"Q"[N],"C"[N],"I"[N],"M"[N],"NC"[N],"DC"[N],"LINK","M"[+]"I"[N],
"X""+"[+'][N],"X""+""C"[N],"ROUND""H""F","ROUND""F","ROUND""H","ROUND","FLOAT""D",
"FLOAT","ERASE","REV""D","REV","ZERO","DUP""D","DUP","NEG""DF","NEG""F",
"NEG""D","NEG","ABS""F","ABS","MAX""F","MAX","SIGN""F","SIGN","CAB","FRB",
"STAND","/""DF","/""D","/""F","/R","/I","/","+""DF","+""D","+""F","+",
"-""DF","-""D","-""F","-","X""DF","X""D","X""F","X""+""F","X""+","=TR","BITS",
"DUMMY","PERM","TOP","OR","VR","NEV","NOT","FIX","STR","CONT",
"AND","EXIT","OUT","X","P"[IOM][ATOF]"Q"[N],"TLOG"[N],
"INTQ"[N],"PARQ"[N],"BUSYQ"[N],"MANUALQ"[N],"CTQ"[N],"CLOQ"[N],
"SET"[+'][N],"ADVCA"[N],[OCTAL]"/"[OCTAL]"/"[OCTAL],[=']"F"[N][E-INSTR],
"JS""E"[N],"J""E"[N],0;

P[J-INSTR]=
"C"[N]"NZ""S","C"[N]"NZ","C"[N]"Z","=""Z","=","#""Z","#",">""Z",">=""Z",
"<""Z","<=""Z","V","NV","EN","NEN","FJ","NFJ","TR","NTR",0;

P[MS-INSTR]=
"QHN","QH","QN","Q","HN","H","N",0;

P[SH-INSTR]=
"A"[+'][N],"AD"[+'][N],"L"[+'][N],"LD"[+'][N],
"C"[+'][N],"AC"[N],"ADC"[N],"LC"[N],"LDC"[N],"CC"[N];

P[QS-INSTR]=
"LINK","Q"[N],"C"[N],"I"[N],"M"[N],"RC"[N],"RI"[N],"RM"[N],
"+Q"[N],"+C+[N],"=I"[N],"+M"[N];

P[+]="+","-";

P[=']="=",0;

P[P']="P",0;

P[IOM]="I","O","M";

P[ATOF]="A","B","C","D","E","F";

P[E-INSTR]="M"[N]"Q","M"[N],0;


P[UI]=
[NAME][APP][SETMARKER1][RESTOFUI],
"->"[N],
"%CAPTION"[CAPTIONTEXT],
"%RETURN",
"%RESULT="[+'][OPERAND][RESTOFEXPR],
"%STOP",
"->"[NAME]"("[+'][OPERAND][RESTOFEXPR]")",
"%MONITOR"[N];


P[SS]=
[UI][SETMARKER2][RESTOFSS1],
"%CYCLE"[NAME][APP]"="[+'][OPERAND][RESTOFEXPR]","[+'][OPERAND][RESTOFEXPR]
","[+'][OPERAND][RESTOFEXPR][S],
"%REPEAT"[S],
[N]":",
[%IU][SC][RESTOFCAND]"%THEN"[UI][S],
"!"[TEXT],
[TYPE][NAME][RESTOFNAMELIST][S],
"%END"[S],
[RT][%SPEC'][NAME][FPP][S],
"%SPEC"[NAME][FPP][S],
"%COMMENT"[TEXT],
[TYPE']"%ARRAY"[NAME][RESTOFNAMELIST]"("[+'][OPERNAD][RESTOFEXPR]":"
[+'][OPERAND][RESTOFEXPR][RESTOFFPP-LIST]")"[RESTOFARRAYLIST][S],
"*""*""*""A"[S],
"%BEGIN"[S],
"%END""%OF""%PROGRAM",
"%UPPER""%CASE""%DELIMITERS"[S],
[NAME]"("[+'][CONST]")"":",
"%SWITCH"[NAME][RESTOFNAMELIST]"("[+'][CONST]":"[CONST]")"[RESTOFSWITCHLIST][S],
"%COMPILE""%QUERIES"[S],
"%IGNORE""%QUERIES"[S],
"%MCODE"[S],
[N]"P"":",
"*"[UCI][S],
"%FAULT"[N][RESTOFN-LIST]"->"[N][RESTOFFAULTLIST][S],
"%NORMAL""%DELIMITERS"[S],
"%STRINGS"[S],
"%END""%OF""%PERM"[S],
"%END""%OF""%MCODE"[S],
"%DEFINE""%COMPILE""%R"[S],
[S];

E
