(* ERROR.PASC: some tokens to test your lexical analyzer on *) (* This code is not legal PASC syntactically and there are even a few *) (* invalid tokens (marked with BADTOKEN comment) which your lexical analyzer *) (* should report as errors. *) this := that; identifiers separated by spaces tabs and newlines onetoken: >= twotokens: > = wouldIpractic_allyspeaking=wanttouseoutrageouslylongidentifiernames := doubtful; (* identifiers begin with a letter followed by letters, numbers, *) (* are they valid ones ? *) foo foo23_a Foo0 (* identifiers cannot contain arbitrary characters *) hcs$terminate (* BADTOKEN *) bell (* BADTOKEN (contains embedded ^G) *) (* number constants *) 1234567890 -17 (* this is two tokens, not one *) 6.02e-23 (* several tokens (PASC doesn't do floats) *) (* character and string constants *) 'a' '\n' (* a newline *) '\t' (* a tab *) '\'' (* an apostrophe *) '\\' (* a backslash *) '\a' (* a character or a string? *) 'dfjdf""sab' ' \\hello\n (* BIP *) AND ARRAY' 'this string is not closed !!! (* string cannot cross line *) (* comments can be multi-line. Comments can contain slash-star like so: (* and this does not imply nes*) ted (*comments and they can contain star like so: * or strings like 'hello'. Furthermore, comments can end with star*slash like so: **) (*********************************************************************** Finally, we conclude with a big comment. Your scanner should handle this even though it exceeds the lex input buffer size. Our "real" trip began with a small plane flight to Ambunti, a mission station on the Sepik river. ((*This flight was six hours late, so we had some time on the beach next to the airport.) The Sepik is a very large, flat, muddy river with lots of curves and oxbow lakes. **) (*It flows from the Irian Jaya border to the ocean between Wewak and Madang. We travelled on the river for six days in a large dugout canoe. *) (****jump up and down while shouting. How this relates to their original culture is unclear. BEGIN x := 17; END --- these keywords are part of the comment, so they should not be recognized. ***********************************************************************) BEGIN x := 17; END (* but outside the comment they should of course *) 13 ... -56 (* the '...' correspond to two token: DOTDOT and DOT *) (* end *) (* This Comment Is Not Closed !!!