I will be using petit parser at some point. Im currently doing it by hand to
learn smalltalk and to get used to the requirements and all the things that
come up. I think when I have a good grip on these I can move on to PetitParser.
I made sure no weird characters are there but still doesn't work.
Attached is the whole thing.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of stephane ducasse
Sent: Saturday, March 23, 2013 2:51 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] Method Calling Inside Nested Blocks
the following in syntactically valid.
May be you pasted a strange character in your method.
> anythingElseBoolean = false ifFalse: [
> doctypeString := reader next: 6.
> doctypeString asLowercase = 'public' ifTrue: [
> AfterDOCTYPEPublicKeywordState value:
> currentCharacter
> ]
]
Now I think that building a HTML parser by hand in 2012 is a strange exercise
when there are compiler compiler or cool framework for parsing like PetitParser.
Stef
AfterDOCTYPENameState: character
|currentCharacter anythingElseBoolean NULL CHARACTERTABULATION LINEFEED
FORMFEED SPACE SOLIDUS GREATERTHANSIGN docTypeToken doctypeString|
CHARACTERTABULATION := 0009 asCharacter.
LINEFEED := 00010 asCharacter .
FORMFEED := 00012 asCharacter .
SPACE := 0020 asCharacter .
currentCharacter := reader next.
currentCharacter = CHARACTERTABULATION ifTrue: [anythingElseBoolean:= false
AfterDOCTYPENameState value: currentCharacter ].
currentCharacter = LINEFEED ifTrue: [anythingElseBoolean:= false
AfterDOCTYPENameState value: currentCharacter ].
currentCharacter =FORMFEED ifTrue: [anythingElseBoolean:= false
AfterDOCTYPENameStatevalue: currentCharacter ].
currentCharacter = SPACE ifTrue: [anythingElseBoolean:= false
AfterDOCTYPENameStatevalue: currentCharacter ].
currentCharacter = GREATERTHANSIGN ifTrue: [anythingElseBoolean:= false
DataState value: currentCharacter ]."Tag emited earlier"
currentCharacter = nil ifTrue: [anythingElseBoolean:= false
parseError signal: 'Parse error'
docTypeToken DocTypeToken new
docTypeToken tokens removeLast
docTypeToken forceQuirksFlag value: 'on'
reader back
DataState value: currentCharacter
].
anythingElseBoolean = false ifFalse: [
doctypeString := reader next: 6.
doctypeString asLowercase = 'public' ifTrue:
[AfterDOCTYPEPublicKeywordState value: currentCharacter ].
reader back
parseError signal: 'Parse error'
BeforeAttributeNameState value: currentCharacter].
"Consume the next input character:
U+0009 CHARACTER TABULATION (tab)
U+000A LINE FEED (LF)
U+000C FORM FEED (FF)
U+0020 SPACE
Ignore the character.
U+003E GREATER-THAN SIGN (>)
Switch to the data state. Emit the current DOCTYPE token.
EOF
Parse error. Switch to the data state. Set the DOCTYPE token's force-quirks
flag to on. Emit that DOCTYPE token. Reconsume the EOF character.
Anything else
If the six characters starting from the current input character are an
ASCII case-insensitive match for the word PUBLIC, then consume those characters
and switch to the after DOCTYPE public keyword state.
Otherwise, if the six characters starting from the current input character
are an ASCII case-insensitive match for the word SYSTEM, then consume those
characters and switch to the after DOCTYPE system keyword state.
Otherwise, this is a parse error. Set the DOCTYPE token's force-quirks flag
to on. Switch to the bogus DOCTYPE state.
"