scanner //NOTE: All transitions except 256 should be converted to characters... simple1 = $+; //Should default to "RK" simple2 = $" [noKeep]; //Should have attribute "R" simple3 = {$"}; //Braces means LOOK. Should have attribute "L" or "" digit = "0123"; //There should be 4 transitions. The attribute should be "RK". (note: character $0 is ascii 48) alternativeDigit = $0 .. $3; //4 transitions. Note: ascii 48, ... anotherAlternativeDigit = 0 .. 3; //4 transition. Note: ascii 0, ... anotherAlternativeDigitAgain = 0 | 1 | 2 | 3; //Uses standard or routine. Note: ascii 0, ... endOfFileCharacter = 256; //Cannot be converted to a character. space = 32 [noKeep]; //The attribute should be "R". lineEnd = 10 [noKeep]; all = "0123abc;+-/" [read keep] | space | lineEnd; //Space and lineEnd should be "R"; others "RK". //Comment = // ($/ [noKeep] {all - $/} #syntaxError: ["// is a comment, / alone is not valid"]) // | ($/ [noKeep] $/ [noKeep] // (all [noKeep] - lineEnd [noKeep])* // ( // lineEnd [noKeep] | // {endOfFileCharacter} // ) // ); //The following are ROOT building semantic actions; i.e., TOKEN BUILDING. //Also, note that parameters should be characters, integers, or strings depending //on whether their labels are #walkCharacter: #walkInteger:, or #walkString:. number = digit+ => Number; //This should create sementic transition #buildToken: with parameters "Number", a string, NOT a token). fsm1 = $a => "bird"; //This one should create semantic transition #buildToken: with parameters containing "bird" (NOT A TOKEN). fsm2 = $b => #buildBirdRoutine:with: [1 2]; //This one should create semantic transition #buildBirdRoutine: with parameters containing integers 1 and 2. fsm3 = $c => #between:and: [10 20]; //This one should create semantic transition #between:and: with parameters containing integers 10 and 20. fsm4 = $d => #testing; //This one should create semantic transition #testing with parameters consisting of an empty collection. //The following are NON-ROOT building semantic actions fsm5 = $e [node] #normalIncludes:and: [30 40]; //This one should create semantic transition #normalIncludes:and: with integer parameters 30 and 40. fsm6 = $f [node] #normalIncludes: [50]; //This one should create semantic transition #normalIncludes: with parameters consisting of integer 50. fsm7 = $g [node] #normalAction; //This one should create semantic transition #normalAction with parameters consisting of an empty collection. //NOTE: not implementing - in this assignment. //nonDigit = {all - digit}; //The attributes should be "L" or "" or "K"; i.e., NOT CONTAINING R.