Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27

Thread: a text parser

  1. #11

    Re: a text parser

    Anyhow... maybe when I get the competition site sorted we could have a regular... 'see who can do it fastest/smallest competition'... just a thought
    Seems that's a good idea.

  2. #12

    Re: a text parser

    Quote Originally Posted by Mirage
    Anyhow... maybe when I get the competition site sorted we could have a regular... 'see who can do it fastest/smallest competition'... just a thought
    Seems that's a good idea.
    very good
    From brazil (:

    Pascal pownz!

  3. #13

    Re: a text parser

    Quote Originally Posted by AthenaOfDelphi
    As for writing a JSON parser... I don't want to discourage anyone from learning, but I also wouldn't encourage re-inventing the wheel (unless of course the wheel you were looking at was square). There is already a JSON parser for Delphi, so if it were me, I'd look at their code, see if could be optimised... and if not... work on something else
    it must work in freepascal too, the code there uses variants and is "not lightweight enough".
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  4. #14
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Re: a text parser

    Quote Originally Posted by Delfi
    it must work in freepascal too, the code there uses variants and is "not lightweight enough".
    Then that sounds like a case of re-inventing the wheel... where the original is square

    Good luck with that when you get round to it.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #15
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Re: a text parser

    Given the usefulness of this little session, I've added it to the library in a newly created code snippets section here
    :: AthenaOfDelphi :: My Blog :: My Software ::

  6. #16

    Re: a text parser

    AthenaOfDelphi's and consequently Arthurps's code for some reason separate also by the "." character, which makes it impossible to parse floating point values (think "123.45" ) and also "0D0A" newlines which isnt neccesary but they dont parse the tab #09.
    This is easy to fix tho just by removing extra IF condition.

    Arthurps's code also doesnt parse properly if you use several separators to separate values (think grid space / tab aligned values): it produces empty values in the array.

    So correct characters for separating should be:
    (aChar = (' ')) or (aChar = (';')) or
    (aChar = (',')) or (aChar = (#09))

    I didn't test User137 and Brainer's code since they use classes.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  7. #17
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Re: a text parser

    Quote Originally Posted by Delfi
    AthenaOfDelphi's and consequently Arthurps's code for some reason separate also by the "." character, which makes it impossible to parse floating point values (think "123.45" ).
    This is easy to fix tho just by removing extra IF condition.

    I didn't test User137 and Brainer's code since they use classes.
    I just banged in a bunch of separators without really thinking about it too much. I normally use things like INI files, type files or streamed classes for data storage... depends on the application.

    Of course, we perhaps shouldn't have included , either since that works as the decimal separator depending on location... just a thought
    :: AthenaOfDelphi :: My Blog :: My Software ::

  8. #18

    Re: a text parser

    http://en.wikipedia.org/wiki/Decimal_separator

    The list is faulty, i've been always taught to use decimal point and the list shows slovenia as using a decimal colon.. practically everyone uses decimal point these days.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  9. #19

    Re: a text parser

    yes "dot" should be removed, but it's very easy to modify the tokens separators "ifs"
    From brazil (:

    Pascal pownz!

  10. #20

    Re: a text parser

    Quote Originally Posted by arthurprs
    yes "dot" should be removed, but it's very easy to modify the tokens separators "ifs"
    That's true and i changed it, and after that Athena's code works but your code has another issue - i quote myself:

    Arthurps's code also doesnt parse properly if you use several separators to separate values (think grid space / tab aligned values): it produces empty values in the array.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •