[Faxpp-devel] SF.net SVN: faxpp: [37] trunk/faxpp
Status: Beta
Brought to you by:
jpcs
From: <jp...@us...> - 2008-02-25 12:05:15
|
Revision: 37 http://faxpp.svn.sourceforge.net/faxpp/?rev=37&view=rev Author: jpcs Date: 2008-02-25 04:05:13 -0800 (Mon, 25 Feb 2008) Log Message: ----------- Implemented tokenization of notation declarations. Modified Paths: -------------- trunk/faxpp/Makefile.am trunk/faxpp/Makefile.in trunk/faxpp/include/faxpp/error.h trunk/faxpp/include/faxpp/token.h trunk/faxpp/src/doctype.c trunk/faxpp/src/error.c trunk/faxpp/src/token.c trunk/faxpp/src/tokenizer_states.c trunk/faxpp/src/tokenizer_states.h trunk/faxpp/src/xml_parser.c Added Paths: ----------- trunk/faxpp/src/notationdecl.c Modified: trunk/faxpp/Makefile.am =================================================================== --- trunk/faxpp/Makefile.am 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/Makefile.am 2008-02-25 12:05:13 UTC (rev 37) @@ -34,7 +34,8 @@ src/xml_tokenizer.h \ src/doctype.c \ src/elementdecl.c \ -src/attlistdecl.c +src/attlistdecl.c \ +src/notationdecl.c tokenizer_example_SOURCES = examples/tokenizer_example.c tokenizer_example_LDADD = libfaxpp.la Modified: trunk/faxpp/Makefile.in =================================================================== --- trunk/faxpp/Makefile.in 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/Makefile.in 2008-02-25 12:05:13 UTC (rev 37) @@ -63,7 +63,8 @@ am_libfaxpp_la_OBJECTS = buffer.lo cdata.lo char_classes.lo comment.lo \ element.lo error.lo event.lo pi.lo reference.lo token.lo \ tokenizer_states.lo transcode.lo xmldecl.lo xml_parser.lo \ - xml_tokenizer.lo doctype.lo elementdecl.lo attlistdecl.lo + xml_tokenizer.lo doctype.lo elementdecl.lo attlistdecl.lo \ + notationdecl.lo libfaxpp_la_OBJECTS = $(am_libfaxpp_la_OBJECTS) libfaxpp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -254,7 +255,8 @@ src/xml_tokenizer.h \ src/doctype.c \ src/elementdecl.c \ -src/attlistdecl.c +src/attlistdecl.c \ +src/notationdecl.c tokenizer_example_SOURCES = examples/tokenizer_example.c tokenizer_example_LDADD = libfaxpp.la @@ -386,6 +388,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elementdecl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/notationdecl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parser_example.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reference.Plo@am__quote@ @@ -545,6 +548,13 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o attlistdecl.lo `test -f 'src/attlistdecl.c' || echo '$(srcdir)/'`src/attlistdecl.c +notationdecl.lo: src/notationdecl.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT notationdecl.lo -MD -MP -MF $(DEPDIR)/notationdecl.Tpo -c -o notationdecl.lo `test -f 'src/notationdecl.c' || echo '$(srcdir)/'`src/notationdecl.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/notationdecl.Tpo $(DEPDIR)/notationdecl.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='src/notationdecl.c' object='notationdecl.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o notationdecl.lo `test -f 'src/notationdecl.c' || echo '$(srcdir)/'`src/notationdecl.c + parser_example.o: examples/parser_example.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT parser_example.o -MD -MP -MF $(DEPDIR)/parser_example.Tpo -c -o parser_example.o `test -f 'examples/parser_example.c' || echo '$(srcdir)/'`examples/parser_example.c @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/parser_example.Tpo $(DEPDIR)/parser_example.Po Modified: trunk/faxpp/include/faxpp/error.h =================================================================== --- trunk/faxpp/include/faxpp/error.h 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/include/faxpp/error.h 2008-02-25 12:05:13 UTC (rev 37) @@ -54,6 +54,7 @@ INVALID_DTD_DECL, INVALID_CHAR_IN_ELEMENTDECL_NAME, INVALID_CHAR_IN_ATTLISTDECL_NAME, + INVALID_CHAR_IN_NOTATIONDECL_NAME, OUT_OF_MEMORY, ELEMENT_NAME_MISMATCH, Modified: trunk/faxpp/include/faxpp/token.h =================================================================== --- trunk/faxpp/include/faxpp/token.h 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/include/faxpp/token.h 2008-02-25 12:05:13 UTC (rev 37) @@ -80,6 +80,9 @@ ATTLISTDECL_NAME_TOKEN, ATTLISTDECL_CONTENT_TOKEN, + NOTATIONDECL_NAME_TOKEN, + NOTATIONDECL_CONTENT_TOKEN, + END_OF_BUFFER_TOKEN = 99 } FAXPP_TokenType; Modified: trunk/faxpp/src/doctype.c =================================================================== --- trunk/faxpp/src/doctype.c 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/src/doctype.c 2008-02-25 12:05:13 UTC (rev 37) @@ -549,6 +549,9 @@ case 'A': env->state = attlistdecl_initial_state1; break; + case 'N': + env->state = notationdecl_initial_state1; + break; LINE_ENDINGS default: env->state = comment_content_state; Modified: trunk/faxpp/src/error.c =================================================================== --- trunk/faxpp/src/error.c 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/src/error.c 2008-02-25 12:05:13 UTC (rev 37) @@ -103,6 +103,8 @@ return "INVALID_CHAR_IN_ELEMENTDECL_NAME"; case INVALID_CHAR_IN_ATTLISTDECL_NAME: return "INVALID_CHAR_IN_ATTLISTDECL_NAME"; + case INVALID_CHAR_IN_NOTATIONDECL_NAME: + return "INVALID_CHAR_IN_NOTATIONDECL_NAME"; case NO_ERROR: break; } Added: trunk/faxpp/src/notationdecl.c =================================================================== --- trunk/faxpp/src/notationdecl.c (rev 0) +++ trunk/faxpp/src/notationdecl.c 2008-02-25 12:05:13 UTC (rev 37) @@ -0,0 +1,110 @@ +/* + * Copyright 2007 Doxological Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "tokenizer_states.h" +#include "char_classes.h" + +#define SINGLE_CHAR_STATE(name, ch, next_stored_state, next_state, error) \ +FAXPP_Error \ +name(FAXPP_TokenizerEnv *env) \ +{ \ + read_char(env); \ +\ + switch(env->current_char) { \ + case (ch): \ + if((next_stored_state) != 0) env->stored_state = (next_stored_state); \ + env->state = (next_state); \ + next_char(env); \ + break; \ + LINE_ENDINGS \ + default: \ + next_char(env); \ + return (error); \ + } \ + return NO_ERROR; \ +} + +SINGLE_CHAR_STATE(notationdecl_initial_state1, 'O', 0, notationdecl_initial_state2, INVALID_DTD_DECL) +SINGLE_CHAR_STATE(notationdecl_initial_state2, 'T', 0, notationdecl_initial_state3, INVALID_DTD_DECL) +SINGLE_CHAR_STATE(notationdecl_initial_state3, 'A', 0, notationdecl_initial_state4, INVALID_DTD_DECL) +SINGLE_CHAR_STATE(notationdecl_initial_state4, 'T', 0, notationdecl_initial_state5, INVALID_DTD_DECL) +SINGLE_CHAR_STATE(notationdecl_initial_state5, 'I', 0, notationdecl_initial_state6, INVALID_DTD_DECL) +SINGLE_CHAR_STATE(notationdecl_initial_state6, 'O', 0, notationdecl_initial_state7, INVALID_DTD_DECL) +SINGLE_CHAR_STATE(notationdecl_initial_state7, 'N', notationdecl_name_state1, ws_plus_state, INVALID_DTD_DECL) + +FAXPP_Error +notationdecl_name_state1(FAXPP_TokenizerEnv *env) +{ + read_char(env); + + switch(env->current_char) { + LINE_ENDINGS + default: + env->state = notationdecl_name_state2; + next_char(env); + if((FAXPP_char_flags(env->current_char) & env->ncname_start_char) == 0) + return INVALID_CHAR_IN_NOTATIONDECL_NAME; + break; + } + + return NO_ERROR; +} + +FAXPP_Error +notationdecl_name_state2(FAXPP_TokenizerEnv *env) +{ + while(1) { + read_char(env); + + switch(env->current_char) { + WHITESPACE: + env->stored_state = notationdecl_content_state; + env->state = ws_state; + token_end_position(env); + report_token(NOTATIONDECL_NAME_TOKEN, env); + next_char(env); + return NO_ERROR; + default: + break; + } + + next_char(env); + if((FAXPP_char_flags(env->current_char) & env->ncname_char) == 0) + return INVALID_CHAR_IN_NOTATIONDECL_NAME; + } + + // Never happens + return NO_ERROR; +} + +FAXPP_Error +notationdecl_content_state(FAXPP_TokenizerEnv *env) +{ + read_char(env); + + switch(env->current_char) { + case '>': + base_state(env); + report_token(NOTATIONDECL_CONTENT_TOKEN, env); + break; + LINE_ENDINGS + default: + break; + } + next_char(env); + return NO_ERROR; +} + Modified: trunk/faxpp/src/token.c =================================================================== --- trunk/faxpp/src/token.c 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/src/token.c 2008-02-25 12:05:13 UTC (rev 37) @@ -111,6 +111,11 @@ case ATTLISTDECL_CONTENT_TOKEN: return "ATTLISTDECL_CONTENT_TOKEN"; + case NOTATIONDECL_NAME_TOKEN: + return "NOTATIONDECL_NAME_TOKEN"; + case NOTATIONDECL_CONTENT_TOKEN: + return "NOTATIONDECL_CONTENT_TOKEN"; + case NO_TOKEN: break; } Modified: trunk/faxpp/src/tokenizer_states.c =================================================================== --- trunk/faxpp/src/tokenizer_states.c 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/src/tokenizer_states.c 2008-02-25 12:05:13 UTC (rev 37) @@ -510,6 +510,29 @@ else if(state == attlistdecl_content_state) return "attlistdecl_content_state"; + else if(state == notationdecl_initial_state1) + return "notationdecl_initial_state1"; + else if(state == notationdecl_initial_state1) + return "notationdecl_initial_state1"; + else if(state == notationdecl_initial_state2) + return "notationdecl_initial_state2"; + else if(state == notationdecl_initial_state3) + return "notationdecl_initial_state3"; + else if(state == notationdecl_initial_state4) + return "notationdecl_initial_state4"; + else if(state == notationdecl_initial_state5) + return "notationdecl_initial_state5"; + else if(state == notationdecl_initial_state6) + return "notationdecl_initial_state6"; + else if(state == notationdecl_initial_state7) + return "notationdecl_initial_state7"; + else if(state == notationdecl_name_state1) + return "notationdecl_name_state1"; + else if(state == notationdecl_name_state2) + return "notationdecl_name_state2"; + else if(state == notationdecl_content_state) + return "notationdecl_content_state"; + return "unknown"; } #endif Modified: trunk/faxpp/src/tokenizer_states.h =================================================================== --- trunk/faxpp/src/tokenizer_states.h 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/src/tokenizer_states.h 2008-02-25 12:05:13 UTC (rev 37) @@ -303,7 +303,18 @@ FAXPP_Error attlistdecl_name_seen_colon_state2(FAXPP_TokenizerEnv *env); FAXPP_Error attlistdecl_content_state(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_initial_state1(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_initial_state2(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_initial_state3(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_initial_state4(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_initial_state5(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_initial_state6(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_initial_state7(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_name_state1(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_name_state2(FAXPP_TokenizerEnv *env); +FAXPP_Error notationdecl_content_state(FAXPP_TokenizerEnv *env); + /********************* * * Tokenizer Helper Functions Modified: trunk/faxpp/src/xml_parser.c =================================================================== --- trunk/faxpp/src/xml_parser.c 2008-02-24 02:26:52 UTC (rev 36) +++ trunk/faxpp/src/xml_parser.c 2008-02-25 12:05:13 UTC (rev 37) @@ -826,6 +826,8 @@ case ATTLISTDECL_PREFIX_TOKEN: case ATTLISTDECL_NAME_TOKEN: case ATTLISTDECL_CONTENT_TOKEN: + case NOTATIONDECL_NAME_TOKEN: + case NOTATIONDECL_CONTENT_TOKEN: // TBD - jpcs break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |