Uses a StreamTokenizer to convert an ImageJ macro file into a token stream.
(String program)
| 14 | |
| 15 | /** Uses a StreamTokenizer to convert an ImageJ macro file into a token stream. */ |
| 16 | public Program tokenize(String program) { |
| 17 | if (program.contains("/*") && program.contains("*/")) |
| 18 | program = addSpacesToEmptyLines(program); |
| 19 | st = new StreamTokenizer(new StringReader(program)); |
| 20 | st.ordinaryChar('-'); |
| 21 | st.ordinaryChar('/'); |
| 22 | st.ordinaryChar('.'); |
| 23 | st.wordChars('_', '_'); |
| 24 | st.whitespaceChars(128, 255); |
| 25 | st.slashStarComments(true); |
| 26 | st.slashSlashComments(true); |
| 27 | pgm = new Program(); |
| 28 | do { |
| 29 | getToken(); |
| 30 | addToken(); |
| 31 | } while (token!=EOF); |
| 32 | if (pgm.hasFunctions) |
| 33 | addUserFunctions(); |
| 34 | //IJ.log(program.length()+" "+pgm.getSize()+" "+IJ.d2s((double)program.length()/pgm.getSize(),1)+" "+program.length()/10); |
| 35 | return pgm; |
| 36 | } |
| 37 | |
| 38 | final void getToken() { |
| 39 | try { |
no test coverage detected