[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

python 2 to 3 converter

jfong at ms4.hinet.net wrote:
> Even string is hard to be handled by the AI:-)
> Quoted from https://portingguide.readthedocs.io/en/latest/strings.html
> " ... This means that you need to go through the entire codebase, and decide which value is what type. Unfortunately, this process generally cannot be automated."

  i don't agree.  if the language is already parsed then
you have the strings.  the contents of the strings will
have to be finite if they are fixed strings.  so to convert
a fixed string you can choose a type for the value and run
a test to see if it works.  if it does then you've picked 
the correct type, if it doesn't you pick the next type.
there are only a finite number of types.

  yes it is brute force but it would find something that
worked eventually if there was something to be found.

  for programs using indefinite strings via input you
can't predict what those would be doing, but then of
course you would be able to say the most general type could 
be tried first and then run tests to see if it worked.

  the overall patterns to try for a string could be 
driven by examining code which has already been converted
that contains similar patterns - eventually you would
have enough of an idea of which things to try first to
speed things up.

  yes, this is a generally hard issue if you are talking
random strings and not sure what is what, but in the
case of a computer language it is already specified and
parsers already exist.