Class BasicCParser
- java.lang.Object
-
- org.apache.commons.imaging.common.BasicCParser
-
public class BasicCParser extends java.lang.ObjectA 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 Modifier and Type Field Description private java.io.PushbackInputStreamis
-
Constructor Summary
Constructors Constructor Description BasicCParser(java.io.ByteArrayInputStream is)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static intappendHex(int i, java.lang.StringBuilder stringBuilder, java.lang.String string)Parses the hexadecimal-base escape-sequence found at indexiofstring.private static intappendOct(int i, java.lang.StringBuilder stringBuilder, java.lang.String string)Parses the octal-base escape-sequence found at indexiofstring.java.lang.StringnextToken()private static intparseEscape(int i, java.lang.StringBuilder stringBuilder, java.lang.String string)Parses thei:thescape-char in the inputstringand appends it tostringBuilder.static java.io.ByteArrayOutputStreampreprocess(java.io.InputStream is, java.lang.StringBuilder firstComment, java.util.Map<java.lang.String,java.lang.String> defines)static java.lang.String[]tokenizeRow(java.lang.String row)static voidunescapeString(java.lang.StringBuilder stringBuilder, java.lang.String string)
-
-
-
Method Detail
-
appendHex
private static int appendHex(int i, java.lang.StringBuilder stringBuilder, java.lang.String string) throws ImagingExceptionParses 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
private static int appendOct(int i, java.lang.StringBuilder stringBuilder, java.lang.String string)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, java.lang.StringBuilder stringBuilder, java.lang.String string) throws ImagingExceptionParses 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 java.io.ByteArrayOutputStream preprocess(java.io.InputStream is, java.lang.StringBuilder firstComment, java.util.Map<java.lang.String,java.lang.String> defines) throws java.io.IOException, ImagingException- Throws:
java.io.IOExceptionImagingException
-
tokenizeRow
public static java.lang.String[] tokenizeRow(java.lang.String row)
-
unescapeString
public static void unescapeString(java.lang.StringBuilder stringBuilder, java.lang.String string) throws ImagingException- Throws:
ImagingException
-
nextToken
public java.lang.String nextToken() throws java.io.IOException, ImagingException- Throws:
java.io.IOExceptionImagingException
-
-