MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / tokenize

Method tokenize

ij/src/main/java/ij/macro/Tokenizer.java:16–36  ·  view source on GitHub ↗

Uses a StreamTokenizer to convert an ImageJ macro file into a token stream.

(String program)

Source from the content-addressed store, hash-verified

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 {

Callers 7

runMethod · 0.95
evalMethod · 0.95
installMethod · 0.95
getToolNameMethod · 0.95
applyMacroMethod · 0.45
getNumParamsMethod · 0.45
applyMacroMethod · 0.45

Calls 5

addSpacesToEmptyLinesMethod · 0.95
getTokenMethod · 0.95
addTokenMethod · 0.95
addUserFunctionsMethod · 0.95
containsMethod · 0.45

Tested by

no test coverage detected