DIRECTORY Commander USING [CommandProc, Register], CommandTool USING [ArgumentVector, Failed, Parse], FS USING [Error, StreamOpen], IO USING [STREAM, PutF, PutRope, rope], Lex822, Rope USING [ROPE, Cat, Length, Equal]; TestLex: CEDAR PROGRAM IMPORTS Commander, CommandTool, FS, IO, Rope, Lex822 = BEGIN LexMessage: Commander.CommandProc = { argv: CommandTool.ArgumentVector = CommandTool.Parse[cmd ! CommandTool.Failed => {cmd.out.PutRope[errorMsg]; GOTO GoAway}]; file: IO.STREAM _ FS.StreamOpen[argv[1] ! FS.Error => {cmd.out.PutRope[error.explanation]; GOTO GoAway}]; token, whiteSpace: Rope.ROPE; tokType: Lex822.TokenType; DO token _ Lex822.LexFieldName[file].fieldName; IF Rope.Equal[token, "\n"] THEN ERROR ELSE IF token.Length[] = 0 THEN EXIT; cmd.out.PutRope[token.Cat["\n"]]; DO [token, whiteSpace, tokType] _ Lex822.LexToken[file]; IF tokType = errorTok THEN cmd.out.PutRope["** Error **\n "]; cmd.out.PutF["\"%h\", \"%h\"\n", IO.rope[whiteSpace], IO.rope[token]]; IF tokType = EOLTok THEN EXIT; ENDLOOP; ENDLOOP; EXITS GoAway => NULL }; Commander.Register["Lex822", LexMessage, "Do a lexical analysis of a message (in a file)."]; END. ΔTestLex.mesa, test program for Lex822. Last edited by HGM, February 27, 1984 9:29:38 pm PST Last edited by Nichols.pa, June 7, 1983 4:55 pm Last Edited by: Taft, September 13, 1983 10:41 am Κƒ˜head™&Ibody™4L™/L™1code2šΟk ˜ Mšœ œ˜(Mšœ œ!˜2Mšœœ˜Mšœœœ˜'Mšœ˜Mšœœœ˜&——šœ œ˜Mšœ-˜4Mšœ˜šΟn œ˜%šœ:˜:Mšœ2œ ˜@—šœ œ˜)Mšœ1œ ˜?—Mšœœ˜M˜M˜š˜Mšœ,˜,Mšœ ˜%Mšœœœœ˜%Mšœ!˜!š˜M˜5Mšœœ#˜=MšœF˜FMšœœœ˜Mš˜—Mš˜—š˜Mšœ ˜—M˜—Mšœ\˜\Mšœ˜——…—~Ε