Class BasicCParser
java.lang.Object
org.apache.commons.imaging.common.BasicCParser
A rudimentary preprocessor and parser for the C programming language.
FIXME replace this by a parser generated via ANTLR (if we really need it?!)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intappendHex(int i, StringBuilder stringBuilder, String string) Parses the hexadecimal-base escape-sequence found at indexiofstring.private static intappendOct(int i, StringBuilder stringBuilder, String string) Parses the octal-base escape-sequence found at indexiofstring.private static intparseEscape(int i, StringBuilder stringBuilder, String string) Parses thei:thescape-char in the inputstringand appends it tostringBuilder.static ByteArrayOutputStreampreprocess(InputStream is, StringBuilder firstComment, Map<String, String> defines) static String[]tokenizeRow(String row) static voidunescapeString(StringBuilder stringBuilder, String string)
-
Field Details
-
is
-
-
Constructor Details
-
BasicCParser
-
-
Method Details
-
appendHex
private static int appendHex(int i, StringBuilder stringBuilder, String string) throws ImagingException Parses the hexadecimal-base escape-sequence found at indexiofstring.Helper-function for
unescapeString().- Parameters:
i- the index of the escape-sequence in the stringstringBuilder- the stringBuilder to append the escape-char tostring- the string whose chars are parsed- Returns:
- the new index i
- Throws:
ImagingException- Since:
- 1.0-alpha3
-
appendOct
Parses the octal-base escape-sequence found at indexiofstring.Helper-function for
unescapeString().- Parameters:
i- the index of the escape-sequence in the stringstringBuilder- the stringBuilder to append the escape-char tostring- the string whose chars are parsed- Returns:
- the new index i
- Since:
- 1.0-alpha3
-
parseEscape
private static int parseEscape(int i, StringBuilder stringBuilder, String string) throws ImagingException Parses thei:thescape-char in the inputstringand appends it tostringBuilder.Helper-function for
unescapeString().- Parameters:
i- the index of the escape-char in the stringstringBuilder- the stringBuilder to append the escape-char tostring- the string whose chars are parsed- Returns:
- the new index i
- Throws:
ImagingException- Since:
- 1.0-alpha3
-
preprocess
public static ByteArrayOutputStream preprocess(InputStream is, StringBuilder firstComment, Map<String, String> defines) throws IOException, ImagingException- Throws:
IOExceptionImagingException
-
tokenizeRow
-
unescapeString
public static void unescapeString(StringBuilder stringBuilder, String string) throws ImagingException - Throws:
ImagingException
-
nextToken
- Throws:
IOExceptionImagingException
-