• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

Parsing problem for Java datatypes in a Text

I need a logic/algorithm based on Java which can return me the type of the input parameter. The input parameter is a text. But the function has to analyse the text and find out whether the input (can be)/is of type int, String, float or enum or an array of primitive data types.

Eg:

The input parameter is: (("ABC","DEF"), (1,2,3), 5.5, (5.2, 6.2,8.8), (RED, BLUE)). Here the function should return me the result as:

DataType-1 is array of String (as the String are always represented in quotes).
DataType-2 is an array of integers
DataType-3 is of type float
DataType-4 is an array of float
DataType-5 is an array of enum, say Color. (Enum always represented without quotes)

Validation should be taken care for non-matching "(" or")". Also for mixed type datatype not allowed.

Due to time constraint this question is being asked. I am looking for some available parsers or expert solution which is failure-proof. Thanks in Advance.
0
ranjeevrajan
Asked:
ranjeevrajan
  • 2
2 Solutions
 
CEHJCommented:
You could make something with regular expressions
0
 
Mayank SAssociate Director - Product EngineeringCommented:
There are some open-source parser generators in Java:

http://java-source.net/open-source/parser-generators 
0
 
Mayank SAssociate Director - Product EngineeringCommented:
BTW that input parameter is not really correct Java. I don't know what it is supposed to be.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now