Skip to content

Commit

Permalink
quoted attribute values
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@704 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Nov 9, 2009
1 parent 46b21dc commit 385df7e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions topics/exercises/xml2/Makefile
Expand Up @@ -2,6 +2,7 @@ test:
swipl -f RunParser.pro -t "main('input.txt')"

fail:
cat bad.txt
swipl -f RunParser.pro -t "main('bad.txt')"

debug:
Expand Down
13 changes: 6 additions & 7 deletions topics/exercises/xml2/Parser.pro
Expand Up @@ -56,11 +56,10 @@ letters([H|T]) --> letter(H), letters(T).
letters([]) --> [].
letter(H,[H|T],T) :- H >= 0'a, H =< 0'z.

value(V) -->
char(H), chars(T),
{ atom_codes(V,[H|T]) }.
value(Y)-->
string("'"),
string(V),
{\+member(39,V)},
{string_to_list(Y,V)},
string("'").

chars([H|T]) --> char(H), chars(T).
chars([]) --> [].
char(H,[H|T],T) :- H >= 0'a, H =< 0'z.
char(H,[H|T],T) :- H >= 0'0, H =< 0'9.
3 changes: 1 addition & 2 deletions topics/exercises/xml2/bad.txt
@@ -1,4 +1,3 @@
<a x=4 x=5>
<a x='4' x='5'>
<b></b>
<c y=true></c>
</a>
4 changes: 2 additions & 2 deletions topics/exercises/xml2/input.txt
@@ -1,4 +1,4 @@
<a x=4>
<a x='4'>
<b></b>
<c x=2 y=true></c>
<c x='2' y='true'></c>
</a>

0 comments on commit 385df7e

Please sign in to comment.