.. (לתיקייה המכילה) | ||
My regexes are problematic. | |
Use a regex debugger! They let you see exactly what part of the string matches what. Here is a good one, but there are many others. Just be sure you use one that doesn't see . as "any character" but "any character other than \n". | |
קישור: Link: Ссылка: وصلة: | http://regexr.com/ |
How many newlines are between stream and endstream in an empty stream? | |
Two. That is, you're guaranteed to always have one end of line after stream and one *other* end of line before endstream. |
How many stream tokens are in this text? One or two? | |
Two. Like block comments in C, streams end on the first newline + endstream. (Bonus: ask yourselves why. What are the other options, and why are they bad/difficult?) |
What is the order of precedence between errors? | |
First of all, stop at the first error (not only when it is an illegal character - any error). This means whichever error appears first in the stream of characters is to be handled first, then exit() should be called. E.g. if there is an illegal escape character in an unclosed string, the illegal character appears before the (nonexistent) end of the string and so will be handled first. |
Can I assume an upper bound on the length of strings and streams? | |
Yes, 2048 bytes should be more than enough for either. |
What about whitespace? | |
Yes, whitespace should be handled. Any space, horizontal tab, or end of line character that appears outside one of the mentioned tokens is considered whitespace and should be ignored. |
The ascii table says tab is 0B hex, did you mean vertical tab? | |
No, we mean horizontal tab, and the hex value is a mistake. The hex value should be 09. |
Does a comment include the end of line that terminates it? (And as a result: what line number should be printed for comments?) | |
A comment is terminated by the newline and does not include it (as the printing requirement hints). This also means that in line n: %some comment here line n+1: <</Other/Things>> the comment token will be printed in line n. |
If there is an error in a multi-character escape sequence, what should we print in the error? | |
The first character of the sequence, as the error's template indicates. |