PetitParser parsing (Windows) end-of-line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

PetitParser parsing (Windows) end-of-line

Nicolas Anquetil
Trying to parse the 3 possible ends of line: Linux=lf ; MacOS=cr;
Windows=crlf

given the rule:

newline
     ^ #newline asParser / (#cr asParser , #newline asParser optional)

The linux and MacOs tests pass
testNewline1
     ^self parse: String lf rule: #newline.
testNewline2
     ^self parse: String cr rule: #newline.

But the windows one fails !?!?!?!

testNewline3
     ^self parse: String crlf rule: #newline.

Any clue why?

nicolas
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: PetitParser parsing (Windows) end-of-line

Nicolas Anquetil

follow up on this:

if I change the rule for

newline
     ^  (#cr asParser , #newline asParser optional) / #newline asParser

Then all three tests pass.

If anybody as a clue on what's happening ... ?

(with the first version of the rule, the error was: "end of input
expected at 1")

nicolas

On 26/09/12 09:35, Nicolas Anquetil wrote:

> Trying to parse the 3 possible ends of line: Linux=lf ; MacOS=cr;
> Windows=crlf
>
> given the rule:
>
> newline
>     ^ #newline asParser / (#cr asParser , #newline asParser optional)
>
> The linux and MacOs tests pass
> testNewline1
>     ^self parse: String lf rule: #newline.
> testNewline2
>     ^self parse: String cr rule: #newline.
>
> But the windows one fails !?!?!?!
>
> testNewline3
>     ^self parse: String crlf rule: #newline.
>
> Any clue why?
>
> nicolas
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: PetitParser parsing (Windows) end-of-line

Stephan Eggermont-3
In reply to this post by Nicolas Anquetil
>If anybody as a clue on what's happening ... ?

Sounds like #newline asParser already matches on cr, and then
has a remaining character lf.

PPJavaLexicon>lineTerminator

        ^ (Character lf asParser) / (Character cr asParser , (Character lf asParser ) optional )

Stephan


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: PetitParser parsing (Windows) end-of-line

Tudor Girba-2
Exactly :)

Doru

On Thu, Sep 27, 2012 at 10:01 AM, Stephan Eggermont <[hidden email]> wrote:

>>If anybody as a clue on what's happening ... ?
>
> Sounds like #newline asParser already matches on cr, and then
> has a remaining character lf.
>
> PPJavaLexicon>lineTerminator
>
>         ^ (Character lf asParser) / (Character cr asParser , (Character lf asParser ) optional )
>
> Stephan
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev



--
www.tudorgirba.com

"Every thing has its own flow"
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev