Cmd /* Interactive commands */ : eol /* Blank line */ | KBreak LineId eol /* Set break point */ | KCont eol /* Single step one line */ | KCont KNumber eol /* Single step N times */ | DelCmd /* Delete range of lines */ | DumpTreeCmd /* For internal debugging only */ | KEdit eol /* Edit program */ | KHelp eol /* Print general help info */ | ListCmd /* List program */ | LoadCmd /* Load program lines */ | KQuit eol /* Exit */ | RenCmd /* Renumber lines */ | KRun eol /* Run program */ | KRun KLoop KNumber eol /* Run program N times */ | SaveCmd /* Save program */ | KScratch eol /* Clear program workspace */ | KStep eol /* Start in single step mode */ | Stmt eol /* Execute statement */ | OptLineNum OptLineLab Cmt1 /* Add or replace line in program */ | OptLineNum OptLineLab Stmt Cmt2 | ExtraHelp /* Extra help commands */ ; eol /* End-of-line */ : '\n' /* EOL char */ | '!' /* Comment */ ; Cmt1 /* Comment not following Stmt */ : KBang /* '!' char */ | KRem /* Remark */ | '\n' /* EOL char */ ; Cmt2 /* Comment following Stmt */ : KBang /* '!' char */ | '\n' /* EOL char */ ; OptLineLab /* Optional line label */ : /* Blank */ | KLabelId /* Name with suffix ':' */ ; LoadCmd /* Load program or subprogram */ : KLoad OptFileName eol /* Load or reload program */ | KLoadSub FileName eol /* Load subprogram from file */ ; SaveCmd /* Save or resave program */ : KSave OptFileName eol ; OptFileName /* Optional file name */ : /* Blank (requests default) */ | FileName /* File name */ ; FileName /* File name */ : KString /* Quoted string */ ; DelCmd /* Delete program lines */ : KDel Range eol /* KNOWS ABOUT DELETE STRATEGY!!! */ ; Range /* Line number range */ : LineNum /* One line number */ | LineNum KAddop LineNum /* Range of line numbers sep by '-' */ | '%' /* All lines */ ; RenCmd /* Renumber lines */ : KRenum eol /* Renumber all lines */ | KRenum LineNum eol /* Renumber starting at LineNum */ | KRenum KIn Range eol /* Renumber lines in Range */ | KRenum LineNum KIn Range eol /* Renumber lines in Range */ ; OptLineNum /* Optional line number */ : KNoNumber /* Blank gets auto line number */ | LineNum /* Line number */ ; LineNum /* Line number */ : KNumber /* An integer */ ; LineId /* Line identifier */ : KNumber /* Number */ | KId /* Label */ ; LineList /* List of line identifiers */ : LineId | LineList ',' LineId ; ListCmd /* List program lines */ : KList Range eol /* List program lines in range */ | KList eol /* List all program lines */ ; DumpTreeCmd /* Dump interpreter internals */ : KDumpTree Range eol | KDumpTree eol ; Stmt /* Program statement */ : KAssign '@' KId KTo Expr KString | KAssign '@' KId KTo Expr | DataStmt | DimStmt | KEnd | KError KReturn | KError Expr | ForStmt | Function | KGosub LineId | KGoto LineId | IfStmt | InputStmt | LetStmt | KLogfile KIs Expr | KElse | KEndif | MatStmt | KNext KId | KNext KIntId | KOff KError | KOn Expr KGoto LineList | KOn Expr KGosub LineList | KOn KError KGosub LineId | KOn KError KGoto LineId | KOption KString /* Debug options, n = +, -, or number */ /* Bn = print comments */ /* Pn = always output prompt */ /* Fn = line handling */ /* Sn = stack handling */ /* Dn = dim handling */ /* Tn = trace line numbers */ /* Ln = lexical decoder */ | KPause | PrintStmt | KRandomize | KRandomize Expr | KRestore | KReturn | KStop | KStop Expr | KWait Expr | BoardInitStmt /* Frame grabber initialization */ | BoardHWStmt /* Low-level hardware commands */ | BoardStmt /* Frame grabber operation */ | InstStmt /* Instrument init & control */ | ProcDataStmt /* Process data */ | GrabStmt /* Grab or acquire data */ | CalFileStmt /* Cal file manipulation */ | MiscRampStmt /* Misc ramp manipulation */ | error ; DimStmt : KDim DimList ; DimList : DimAnyItem | DimList ',' DimAnyItem ; DimAnyItem : DimItem /* Numbers or default strings */ | DimItem '[' KNumber ']' /* Strings only */ ; DimItem : DimVar '(' Expr ')' | DimVar '(' Expr ',' Expr ')' | DimVar ; DimVar : KId | KStringId | KIntId ; LetStmt : KLet Variable '=' Expr | Variable '=' Expr ; MatStmt : KMat KId '=' KId | KMat KId '=' KId KAddop KId | KMat KId '=' KId KMulop KId | KMat KId '=' '(' Expr ')' | KMat KId '=' '(' Expr ')' KAddop KId | KMat KId '=' '(' Expr ')' KMulop KId | KMat KId '=' KFunction | KMat KId '=' KFunction '(' KId ')' | KMat KId '=' KAddop KId | KMat KId '=' KIdn | KMat KId '=' KZer | KMat KId '=' KInv '(' KId ')' | KMat KId '=' KTrn '(' KId ')' ; IfStmt : KIf Expr KThen ObjStmt KElse ObjStmt | KIf Expr KThen ObjStmt | KIf Expr KThen | KIf Expr KGoto LineId ; ObjStmt : LineId | Stmt ; ForStmt : KFor KId '=' Expr KTo Expr KStep Expr | KFor KId '=' Expr KTo Expr | KFor KIntId '=' Expr KTo Expr KStep Expr | KFor KIntId '=' Expr KTo Expr ; PrintStmt : PrintOut PExprList | PrintOut PExprList Expr | KMat PrintOut MExprList | KMat PrintOut MExprList SimpleVar | KPrinter KIs Expr ; PrintOut : KPrint | KOutput '@' KId ';' ; PExprList : /* empty */ | PExprList PExpr ; PExpr : ',' | ';' | Expr ',' | Expr ';' ; MExprList : /* empty */ | MExprList MExpr ; MExpr : ',' | ';' | SimpleVar ',' | SimpleVar ';' ; InputStmt : KInput VarList | KInput KString ',' VarList /* prompt string */ | KInput KString /* prompt string */ | KRead VarList | KEnter '@' KId ';' VarList | KEnterLine '@' KId ';' VarList | KMat KInput SimpleVarList | KMat KEnter '@' KId ';' SimpleVarList | KMat KRead SimpleVarList ; VarList : Variable | VarList ',' Variable ; SimpleVarList : SimpleVar | SimpleVarList ',' SimpleVar ; DataStmt : KData DExprList ; DExprList : DConstant | KNumber KMulop DConstant | DExprList ',' DConstant | DExprList ',' KNumber KMulop DConstant ; DConstant : Constant | KAddop KNumber ; Constant : KNumber | KMaxReal | KHexInt | KString ; Variable : SimpleVar | SimpleVar '(' Expr ')' | SimpleVar '(' Expr ',' Expr ')' | SimpleVar '(' Expr ',' Expr ',' Expr ')' ; SimpleVar : KId | KStringId | KIntId ; Expr /* Expressions */ : Constant | Variable | Variable '[' Expr ']' /* Substring to end */ | Variable '[' Expr ',' Expr ']' /* Substring to position */ | Variable '[' Expr ';' Expr ']' /* Substring N chars */ | Expr KAddop Expr /* Add operators (+, -) */ | Expr KMulop Expr /* Multiply operators (*, /, &) */ | Expr KExpop Expr /* Exponentiation operator (^) */ | Expr '=' Expr /* Equal operator (assign, relop) */ | Expr KRelop Expr /* Relation ops (<, <=, >, >=, <>) */ | Expr KLogop Expr /* Logical operators (and, or) */ | KAddop Expr %prec UMINUS /* negation */ | KNot Expr /* Logical not */ | '(' Expr ')' /* Grouping with parentheses */ | KDet '(' KId ')' /* Determinant of matrix */ | KDot '(' KId ',' KId ')' /* Dot product of matrix */ | KSum '(' KId ')' /* Sum of matrix */ | KErrl '(' LineId ')' /* Return 1 if error was in line */ | Function /* Function call */ ; Function : KFunction /* Function call with without arguments, without parens */ | KFunction '(' ')' /* Function call without arguments but with parens */ | KFunction '(' Expr ')' /* Function call with 1 argument */ | KFunction '(' Expr ',' Expr ')' /* 2 arguments */ | KFunction '(' Expr ',' Expr ',' Expr ')' /* 3 args */ | KFunction '(' Expr ',' Expr ',' Expr ',' Expr ')' /* 4 args */ | KFunction '(' Expr ',' Expr ',' Expr ',' Expr ',' | KFunction '(' Expr ',' Expr ',' Expr ',' Expr ',' | KFunction '(' Expr ',' Expr ',' Expr ',' Expr ',' | KFunction '(' Expr ',' Expr ',' Expr ',' Expr ',' | KFunction '(' Expr ',' Expr ',' Expr ',' Expr ',' ; ExtraHelp : KHelp KString eol /* Search help text for string */ | KHelp KMore eol /* Show full command list */ | KHelp KGosub eol /* Show all "!!" comment lines */ | KHelp KGosub KString eol /* Search "!!" comment lines for string */ | KHelp KMap eol /* Show hardware address ranges */ ; BoardInitStmt : KReset DfltVal OptVal /* Initialize board hardware */ ; BoardHWStmt : KConfig KLCA OptFileNameExpr /* Configure LCA from file */ | KMap DfltVal /* IOMAP hardware I/O for HW debug */ | KMap KRAM Val /* IOMAP hardware RAM for HW debug */ | ReadHW HWAdrs /* Read a Byte, Short, or Long */ | ReadHW KLoop HWAdrs /* Read until user hits ^C */ | WriteHW HWAdrs Val /* Write a Byte, Short, or Long */ | WriteHW KLoop HWAdrs Val /* Write until user hits ^C */ | WriteHW ReadHW KLoop HWAdrs /* Write/Read i++, loop til ^C */ ; HWAdrs /* To make syntax more readable */ : Constant /* Number */ | SimpleVar ; ReadHW /* Read from harware address */ : KReadB /* Byte */ | KReadS /* Short */ | KReadL /* Long */ ; WriteHW /* Write to hardware address */ : KWriteB /* Byte */ | KWriteS /* Short */ | KWriteL /* Long */ ; BoardStmt : KCursor KClear /* Clear video RAM */ | KCursor Val Val OptVal /* Draw line: angle, location */ /* angle = 0, 45, or 90 */ /* loc = y, -, or x intercept */ /* OptVal = data */ | KCursor Shape Org Size OptVal /* Draw shape: origin, size */ /* OptVal = data */ | KStatus /* Board status */ | KTest KCursor KRAM OptVal /* Test Cursor Ram */ /* OptVal = # of passes */ | KTest KData KRAM OptVal /* Test Data Ram */ /* OptVal = # of passes */ ; Shape : KCirc /* Circle */ | KRect /* Rectangle */ ; Org /* X Y pair for coordinate */ : Val Val ; Size /* X Y pair for coordinate */ : Val Val ; OptVal : /* nothing */ | Val ; DfltVal : KDefault | Val ; Val : Constant | SimpleVar ; InstStmt /* Instrument commands */ : ReadInst KPower /* Read instr power supplies */ | ReadInst KStatus /* Read instr ID & status */ | KReset KInst Val /* Reset instr (0=off 1=on) */ | KReset KInst KMotion /* Reset motion controller */ | KReset KMotion /* Reset motion controller */ | WriteInst KStatus /* Write instr info to EEPROM */ | ReadInst KLLC /* Read instr light level */ | ReadInst KLLC KStatus /* Read instr LLC status */ | WriteInst KLLC LLCVal /* Write instr LLC value or func */ | KDel KInst KRamp KAll /* Delete all ramps from instr */ | KDel KInst KRamp Val /* Delete ramp from instr (index) */ | KLoad KInst KRamp KPmi Val /* Load PMI ramp (N buckets) */ | KLoad KInst KRamp KSwli Val /* Load SWLI ramp (Scan len) */ | KLoad KInst KRamp Val /* Load ramp (index) */ | ReadInst KRamp /* Read instr ramp gain */ | ReadInst KRamp KStatus /* Check instr and ramp status */ | KReset KInst KRamp /* Reset instr PZT power */ | WriteInst KRamp RampVal /* Write instr ramp gain or func */ | WriteInst KRamp Val Val Val /* Write instr ramp triple values */ | WriteInst KRamp KOffset Expr /* Write instr PIFOC offset */ | ReadInst KTurret /* Read instr turret position */ | WriteInst KTurret Val /* Write instr turret positon */ | ReadInst HWAdrs /* Read instr HW address */ | WriteInst HWAdrs Val /* Write instr HW address with data */ ; ReadInst : KRead KInst /* read inst (long version) */ | KReadInst /* ri (short version) */ ; WriteInst : KWrite KInst /* write inst (long version) */ | KWriteInst /* wi (short version) */ ; LLCVal : Val /* Light level value */ | KAuto /* Auto mode */ | KAutoHi /* Auto High mode */ | KBest /* Best setting */ | KBright /* Brightest setting */ | KDark /* Darkest settting */ | KKnob /* Knob (user) mode */ | KMan /* Manual (program control) mode */ | KFunction /* Min or Max (obsolete) */ ; RampVal : Val /* Normal ramp value */ | KDefault /* Value from Cal File */ | KOn /* On */ | KOff /* Off */ | KConn /* Connect normal */ | KConnXR /* Connect XR PZT */ | KDisc /* Disconnect */ ; GrabStmt : KAcquire Val Val /* Acquire (LLC, Cal flags) */ | KGrab Expr /* Grab di.nFrames (Wait-til-done) */ | KCopy KGrab /* Copy di.nFrames grabbed */ | KCopy KLive /* Copy di.nFrames live */ | KWindow /* Show current window */ | KWindow Org Size /* Set window origin and size */ | KWindow KDefault /* Set default window */ ; ProcDataStmt : KCalvert /* Convert to S-Factor */ | KConvert /* Convert to phase */ | KMagvert Val OptVal /* Convert to magnitude bin# (return) */ | KWrite KGrab OptFileNameExpr /* Write grabbed data to file */ | KConnect /* Unwrap phase data */ | KCopy KId KId /* Copy between two data matrices */ | KFit /* Fit surface to height data */ | KPtoV /* Perform Peak-to-Valley analysis */ | KRemove /* Remove surface from height data */ | KSubtract KId KId /* Subtract two data matrices */ | KWrite KData OptFileNameExpr /* Write height data to file */ ; CalFileStmt : KCalFile Expr /* Process string as line in cal file */ | KRead KCalFile OptFileNameExpr /* Read system cal file */ | KRead KRamp Expr /* Read ramp from file */ | KWrite KCalFile OptFileNameExpr /* Write system cal file */ | KWrite KRamp OptFileNameExpr /* Write current ramp to file */ ; MiscRampStmt : KSelect KRamp Val /* Select ramp by index */ | KPrint KRamp OptVal /* Print ramp info, OptVal = index */ | KPrint KRamps /* Print all ramp info */ | KPrint KPmi KRamps /* Print PMI ramp info */ | KPrint KSwli KRamps /* Print SWLI ramp info */ ; OptFileNameExpr : /* Blank (request default) */ | Expr /* String expression */ ;