Permalink
Browse files

Merge pull request #16 from shaneClauson/master

Merge updates from Shane Clauson. Specifically:

- Handle windows style file 'URIs'. Note that this causes a test to fail (but the tests for this need updating).
- Return better information from SAX when it crashes out with an error (approximate line and column numbers).
- Include a copy of a Visual Studio project file.
  • Loading branch information...
andreww committed May 9, 2012
2 parents 1509ab8 + 2b6f477 commit 84fe2093306f7bad0ca85ccd08989ed6010f39c9
Showing with 234 additions and 26 deletions.
  1. +117 −0 FoX.vfproj
  2. +16 −0 Fox.vfproj.README
  3. +16 −14 sax/m_sax_parser.F90
  4. +10 −1 sax/m_sax_reader.F90
  5. +51 −7 sax/m_sax_tokenizer.F90
  6. +24 −4 utils/fox_m_utils_uri.F90
View
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject ProjectType="typeStaticLibrary" ProjectCreator="Intel Fortran" Keyword="Static Library" Version="11.0" >
+ <Platforms>
+ <Platform Name="Win32"/>
+ <Platform Name="x64"/></Platforms>
+ <Configurations>
+ <Configuration Name="Debug|Win32" OutputDirectory="..\lib\" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.pdb;*.log;*.lib" ConfigurationType="typeStaticLibrary">
+ <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" Preprocess="preprocessYes" EnableRecursion="true" F2003Semantics="true" DebugParameter="debugParameterUsed" WarnInterfaces="true" IntegerKIND="integerKIND8" RealKIND="realKIND8" ModulePath="$(OutDir)Modules" PdbFile="$(OutDir)\$(TargetName).pdb" SourceListingFile="" BuildDependenciesFile="" Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebug" DisableDefaultLibSearch="true"/>
+ <Tool Name="VFLibrarianTool" OutputFile="$(OutDir)$(ProjectName)_$(ConfigurationName).lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="libc.lib; libcmt.lib"/>
+ <Tool Name="VFResourceCompilerTool"/>
+ <Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
+ <Tool Name="VFCustomBuildTool"/>
+ <Tool Name="VFPreLinkEventTool"/>
+ <Tool Name="VFPreBuildEventTool"/>
+ <Tool Name="VFPostBuildEventTool" CommandLine=" " Description=" "/>
+ <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
+ <Configuration Name="Release|Win32" OutputDirectory="..\lib\" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="typeStaticLibrary">
+ <Tool Name="VFFortranCompilerTool" AdditionalOptions="/assume:nobscc " SuppressStartupBanner="true" Preprocess="preprocessYes" EnableRecursion="true" F2003Semantics="true" LocalSavedScalarsZero="true" ModulePath="$(OutDir)Modules" PdbFile="$(OutDir)\$(TargetName).pdb" Traceback="true" RuntimeChecks="rtChecksNone" DisableDefaultLibSearch="true"/>
+ <Tool Name="VFLibrarianTool" OutputFile="$(OutDir)$(ProjectName).lib" IgnoreAllDefaultLibraries="true" IgnoreDefaultLibraryNames="libc.lib; libcmt.lib"/>
+ <Tool Name="VFResourceCompilerTool"/>
+ <Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
+ <Tool Name="VFCustomBuildTool"/>
+ <Tool Name="VFPreLinkEventTool"/>
+ <Tool Name="VFPreBuildEventTool"/>
+ <Tool Name="VFPostBuildEventTool" CommandLine=" " Description=" "/>
+ <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
+ <Configuration Name="Debug|x64" OutputDirectory="..\libx64\" ConfigurationType="typeStaticLibrary">
+ <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" Preprocess="preprocessYes" EnableRecursion="true" F2003Semantics="true" DebugParameter="debugParameterUsed" WarnInterfaces="true" ModulePath="$(OutDir)Modules" PdbFile="$(OutDir)\$(TargetName).pdb" SourceListingFile=" " BuildDependenciesFile=" " Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebug" DisableDefaultLibSearch="true"/>
+ <Tool Name="VFLinkerTool" SuppressStartupBanner="true"/>
+ <Tool Name="VFLibrarianTool" OutputFile="$(OutDir)$(ProjectName)_$(ConfigurationName).lib" IgnoreAllDefaultLibraries="true"/>
+ <Tool Name="VFResourceCompilerTool"/>
+ <Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
+ <Tool Name="VFCustomBuildTool"/>
+ <Tool Name="VFPreLinkEventTool"/>
+ <Tool Name="VFPreBuildEventTool"/>
+ <Tool Name="VFPostBuildEventTool" CommandLine=" " Description=" "/>
+ <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
+ <Configuration Name="Release|x64" OutputDirectory="..\libx64\" ConfigurationType="typeStaticLibrary">
+ <Tool Name="VFFortranCompilerTool" AdditionalOptions="/assume:nobscc " SuppressStartupBanner="true" MatrixLibrary="mlYes" Preprocess="preprocessYes" EnableRecursion="true" F2003Semantics="true" LocalSavedScalarsZero="true" ModulePath="$(OutDir)Modules" PdbFile="$(OutDir)\$(TargetName).pdb" SourceListingFile=" " BuildDependenciesFile=" " RuntimeChecks="rtChecksNone" DisableDefaultLibSearch="true"/>
+ <Tool Name="VFLibrarianTool" OutputFile="$(OutDir)$(ProjectName).lib" IgnoreAllDefaultLibraries="true"/>
+ <Tool Name="VFResourceCompilerTool"/>
+ <Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
+ <Tool Name="VFCustomBuildTool"/>
+ <Tool Name="VFPreLinkEventTool"/>
+ <Tool Name="VFPreBuildEventTool"/>
+ <Tool Name="VFPostBuildEventTool" CommandLine=" " Description=" "/>
+ <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration></Configurations>
+ <Files>
+ <Filter Name="Header Files" Filter="fi;fd"/>
+ <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ <File RelativePath=".\DoX\FoX.html"/></Filter>
+ <Filter Name="Source Files" Filter="f90;for;f;fpp;ftn;def;odl;idl">
+ <Filter Name="common">
+ <File RelativePath=".\common\FoX_common.F90"/>
+ <File RelativePath=".\common\m_common_attrs.F90"/>
+ <File RelativePath=".\common\m_common_buffer.F90"/>
+ <File RelativePath=".\common\m_common_charset.F90"/>
+ <File RelativePath=".\common\m_common_content_model.F90"/>
+ <File RelativePath=".\common\m_common_element.F90"/>
+ <File RelativePath=".\common\m_common_elstack.F90"/>
+ <File RelativePath=".\common\m_common_entities.F90"/>
+ <File RelativePath=".\common\m_common_entity_expand.F90"/>
+ <File RelativePath=".\common\m_common_error.F90"/>
+ <File RelativePath=".\common\m_common_io.F90"/>
+ <File RelativePath=".\common\m_common_namecheck.F90"/>
+ <File RelativePath=".\common\m_common_namespaces.F90"/>
+ <File RelativePath=".\common\m_common_notations.F90"/>
+ <File RelativePath=".\common\m_common_struct.F90"/></Filter>
+ <Filter Name="dom">
+ <File RelativePath=".\dom\FoX_dom.f90"/>
+ <File RelativePath=".\dom\m_dom_dom.F90"/>
+ <File RelativePath=".\dom\m_dom_error.f90"/>
+ <File RelativePath=".\dom\m_dom_extras.F90"/>
+ <File RelativePath=".\dom\m_dom_parse.f90"/>
+ <File RelativePath=".\dom\m_dom_utils.f90"/></Filter>
+ <Filter Name="fsys">
+ <File RelativePath=".\fsys\FoX_m_fsys_abort_flush.F90"/>
+ <File RelativePath=".\fsys\FoX_m_fsys_array_str.F90"/>
+ <File RelativePath=".\fsys\fox_m_fsys_count_parse_input.F90"/>
+ <File RelativePath=".\fsys\FoX_m_fsys_format.F90"/>
+ <File RelativePath=".\fsys\FoX_m_fsys_parse_input.F90"/>
+ <File RelativePath=".\fsys\FoX_m_fsys_realtypes.f90"/>
+ <File RelativePath=".\fsys\FoX_m_fsys_string.F90"/>
+ <File RelativePath=".\fsys\FoX_m_fsys_string_list.F90"/>
+ <File RelativePath=".\fsys\fox_m_fsys_varstr.F90"/>
+ <File RelativePath=".\fsys\m_ieee.f90"/></Filter>
+ <Filter Name="sax">
+ <File RelativePath=".\sax\FoX_sax.f90"/>
+ <File RelativePath=".\sax\m_sax_operate.F90"/>
+ <File RelativePath=".\sax\m_sax_parser.F90"/>
+ <File RelativePath=".\sax\m_sax_reader.F90"/>
+ <File RelativePath=".\sax\m_sax_tokenizer.F90"/>
+ <File RelativePath=".\sax\m_sax_types.F90"/>
+ <File RelativePath=".\sax\m_sax_xml_source.F90"/></Filter>
+ <Filter Name="utils">
+ <File RelativePath=".\utils\FoX_m_utils_mtprng.F90"/>
+ <File RelativePath=".\utils\fox_m_utils_uri.F90"/>
+ <File RelativePath=".\utils\FoX_m_utils_uuid.F90"/>
+ <File RelativePath=".\utils\FoX_utils.f90"/></Filter>
+ <Filter Name="wcml">
+ <File RelativePath=".\wcml\FoX_wcml.f90"/>
+ <File RelativePath=".\wcml\m_wcml_coma.F90"/>
+ <File RelativePath=".\wcml\m_wcml_core.F90"/>
+ <File RelativePath=".\wcml\m_wcml_geometry.F90"/>
+ <File RelativePath=".\wcml\m_wcml_lattice.F90"/>
+ <File RelativePath=".\wcml\m_wcml_lists.F90"/>
+ <File RelativePath=".\wcml\m_wcml_metadata.F90"/>
+ <File RelativePath=".\wcml\m_wcml_molecule.F90"/>
+ <File RelativePath=".\wcml\m_wcml_parameter.F90"/>
+ <File RelativePath=".\wcml\m_wcml_property.F90"/>
+ <File RelativePath=".\wcml\m_wcml_stml.F90"/></Filter>
+ <Filter Name="wxml">
+ <File RelativePath=".\wxml\FoX_wxml.f90"/>
+ <File RelativePath=".\wxml\m_wxml_core.F90"/>
+ <File RelativePath=".\wxml\m_wxml_escape.F90"/>
+ <File RelativePath=".\wxml\m_wxml_overloads.F90"/></Filter></Filter></Files>
+ <Globals/></VisualStudioProject>
View
@@ -0,0 +1,16 @@
+FoX.vfproj contains a Visual Studio project for Intel Fortran.
+At time of writing, it is compatible with Visual Studio 2011 and Intel Visual Fortran Composer XE 2011.
+
+The project will build FoX in one of the four configurations - Win32/x64 and debug/release.
+When building FoX for a specific configuration, an output library file Fox_debug.lib or Fox.lib
+and associated modules are created in a folder in a relative path ../lib or ../libx64 respectively.
+
+For a given configuration in in your application project you will then need to
+1) In "Fortran" "General" "Additional Include Directories" add the respective modules folder (generated above)
+2) In "Linker" "General" "Additional library directories" add the path to the respective lib or libx64 folder.
+3) In "Linker" "Input" "Additional dependencies" add Fox_debug.lib or FoX.lib respectively.
+
+Your application should now be able to build and link with FoX.
+
+Best of Luck !
+Shane Clauson.
View
@@ -45,7 +45,7 @@ module m_sax_parser
use m_sax_reader, only: file_buffer_t, pop_buffer_stack, open_new_string, &
open_new_file, parse_xml_declaration, parse_text_declaration, &
- reading_main_file, reading_first_entity
+ reading_main_file, reading_first_entity, add_error_position
use m_sax_tokenizer, only: sax_tokenize, normalize_attribute_text, &
expand_pe_text
use m_sax_types ! everything, really
@@ -889,7 +889,7 @@ end subroutine startEntity_handler
case (TOK_CHAR)
!First, expand all entities:
tempString2 => vs_varstr_alloc(fx%token)
- tempString => normalize_attribute_text(fx, tempString2)
+ tempString => normalize_attribute_text(fx, tempString2, fb)
call varstr_vs( fx%token, tempString )
deallocate(tempString)
deallocate(tempString2)
@@ -1495,13 +1495,15 @@ end subroutine startEntity_handler
if (nextState/=ST_NULL) then
fx%state = nextState
else
- call add_error(fx%error_stack, "Internal error in parser - no suitable token found")
+ call add_error(fx%error_stack, "Internal error in parser - no suitable token found.")
goto 100
endif
end do
-100 if (associated(tempString)) deallocate(tempString)
+100 continue
+ if (in_error(fx%error_stack)) call add_error_position(fx%error_stack, fb)
+ if (associated(tempString)) deallocate(tempString)
if (associated(tempString2)) deallocate(tempString2)
if (associated(extSubsetURI)) call destroyURI(extSubsetURI)
call destroy_string_list(id_list)
@@ -1826,7 +1828,7 @@ subroutine parseDTD
if (associated(elem%attlist%list(i)%default)) then
tempString => elem%attlist%list(i)%default
elem%attlist%list(i)%default => &
- normalize_attribute_text(fx, tempString)
+ normalize_attribute_text(fx, tempString, fb)
deallocate(tempString)
if (in_error(fx%error_stack)) return
endif
@@ -2329,7 +2331,7 @@ subroutine open_tag
call checkAttributes(elem, fx%attributes)
if (.not.checkContentModel(fx%elstack, str_vs(fx%name))) then
call add_error(fx%error_stack, &
- "Element "//str_vs(fx%name)//" not permitted in this context")
+ "Element '"//str_vs(fx%name)//"' not permitted in this context")
return
endif
else
@@ -2338,7 +2340,7 @@ subroutine open_tag
else
if (validCheck) then
call add_error(fx%error_stack, &
- "Trying to use an undeclared element")
+ "Trying to use an unrecognised element '"//str_vs(fx%name)//"'")
return
endif
endif
@@ -2362,7 +2364,7 @@ subroutine open_tag
! no namespace was found for the current element
if (.not.startInCharData_) then
! but we ignore this if we are parsing an entity through DOM
- call add_error(fx%error_stack, "No namespace found for current element")
+ call add_error(fx%error_stack, "No namespace found for current element '"//str_vs(fx%name)//"'")
return
elseif (present(startElement_handler)) then
! Record it as having an empty URI
@@ -2405,8 +2407,8 @@ subroutine close_tag
endif
if (str_vs(fx%name)/=get_top_elstack(fx%elstack)) then
call add_error(fx%error_stack, &
- "Mismatching close tag: trying to close "//get_top_elstack(fx%elstack) &
- //" with "//str_vs(fx%name))
+ "Mismatching close tag: trying to close entity '"//get_top_elstack(fx%elstack) &
+ //"' with '"//str_vs(fx%name)//"'")
return
endif
if (validCheck) then
@@ -2792,7 +2794,9 @@ subroutine checkAttributes(el, dict)
if (str_vs(att%default)//"x"/=str_vs(attValue)//"x") then
! Validity Constraint: Fixed Attribute Default
call add_error(fx%error_stack, &
- "FIXED attribute has wrong value")
+ "FIXED attribute has unexpected value." &
+ //" At Element='"//str_vs(el%name)//"' Attribute='"//str_vs(att%name)//"'" &
+ //" Expecting '"//str_vs(att%default)//"' Found '"//str_vs(attValue)//"'")
return
endif
else
@@ -2810,9 +2814,7 @@ subroutine checkAttributes(el, dict)
end select
enddo
- if (any(attributesLeft)) &
- call add_error(fx%error_stack, &
- "Undeclared attributes forbidden")
+ if (any(attributesLeft)) call add_error(fx%error_stack, "Undeclared attributes forbidden. Element '"//str_vs(el%name)//"'")
end subroutine checkAttributes
View
@@ -26,6 +26,7 @@ module m_sax_reader
public :: file_buffer_t
public :: line
public :: column
+ public :: add_error_position
public :: open_file
public :: close_file
@@ -73,6 +74,7 @@ subroutine open_file(fb, iostat, file, lun, string, es)
fileURI => parseURI(file)
if (.not.associated(fileURI)) then
call add_error(es, "Could not open file "//file//" - not a valid URI")
+ iostat=1
return
endif
call open_new_file(fb, fileURI, iostat, lun)
@@ -169,7 +171,7 @@ subroutine close_file(fb)
call close_actual_file(fb%f(i))
enddo
- deallocate(fb%f)
+ if (associated(fb%f)) deallocate(fb%f)
end subroutine close_file
@@ -397,6 +399,13 @@ function reading_first_entity(fb) result(p)
p = (size(fb%f)==2)
end function reading_first_entity
+
+ subroutine add_error_position(stack, fb)
+ type(error_stack), intent(inout) :: stack
+ type(file_buffer_t), intent(in) :: fb
+ call add_error(stack,"(Possibly near line="//line(fb)//" col="//column(fb)//")")
+ end subroutine add_error_position
+
#endif
end module m_sax_reader
Oops, something went wrong.

0 comments on commit 84fe209

Please sign in to comment.