Class BasicCParser

java.lang.Object
org.apache.commons.imaging.common.BasicCParser

public class BasicCParser extends Object
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 Details

  • Constructor Details

  • Method Details

    • appendHex

      private static int appendHex(int i, StringBuilder stringBuilder, String string) throws ImagingException
      Parses the hexadecimal-base escape-sequence found at index i of string.

      Helper-function for unescapeString().

      Parameters:
      i - the index of the escape-sequence in the string
      stringBuilder - the stringBuilder to append the escape-char to
      string - the string whose chars are parsed
      Returns:
      the new index i
      Throws:
      ImagingException
      Since:
      1.0-alpha3
    • appendOct

      private static int appendOct(int i, StringBuilder stringBuilder, String string)
      Parses the octal-base escape-sequence found at index i of string.

      Helper-function for unescapeString().

      Parameters:
      i - the index of the escape-sequence in the string
      stringBuilder - the stringBuilder to append the escape-char to
      string - 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 the i:th escape-char in the input string and appends it to stringBuilder.

      Helper-function for unescapeString().

      Parameters:
      i - the index of the escape-char in the string
      stringBuilder - the stringBuilder to append the escape-char to
      string - 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:
      IOException
      ImagingException
    • tokenizeRow

      public static String[] tokenizeRow(String row)
    • unescapeString

      public static void unescapeString(StringBuilder stringBuilder, String string) throws ImagingException
      Throws:
      ImagingException
    • nextToken

      public String nextToken() throws IOException, ImagingException
      Throws:
      IOException
      ImagingException