#---------------------------------------------------------------------------* # # @file arxml_scanner.galgas # # @section desc File description # # Scanner for arxml parsing. # # @section copyright Copyright # # Goil OIL compiler, part of Trampoline RTOS # # Trampoline is copyright (c) CNRS, University of Nantes, # Ecole Centrale de Nantes # Trampoline is protected by the French intellectual property law. # # This software is distributed under the GNU Public Licence V2. # Check the LICENSE file in the root directory of Trampoline # # $Date$ # $Rev$ # $Author$ # $URL$ # #---------------------------------------------------------------------------* template lexique arxml_scanner { template "<" %preserved ... "" replace "&" -> "&" replace "<" -> "<" replace ">" -> ">" replace """ -> "\"" replace "'" -> "'" replace "&#" ... ";" : codePointToUnicode style delimitersStyle -> "Delimiter" style nameStyle -> "Name" style attributeValue -> "Attribute value" style commentStyle -> "Comment" style textStyle -> "Text" @string tokenString #-------------------------- comment -------------------- $comment$ ! tokenString style commentStyle %templateEndMark error message "a comment" message incorrectCommentError : "incorrect XML comment" rule "" error incorrectCommentError : enterCharacterIntoString ( !?tokenString !'-' ) end send $comment$ } # ----------------------------- Delimiters --------------------------------------- list xmlDelimitorsList style delimitersStyle error message "the '%K' delimitor" { "<", "" %templateEndMark, "?>" %templateEndMark, "/>" %templateEndMark, "'9' | '-' | ':' : end send $name$ } #-------------------------- Attribute value -------------------- $value$ ! tokenString style attributeValue error message "an attribute value" message incorrectAttributeEnd : "attribute value should be enclosed between apostrophes (') or quotation marks (\")" rule '"' { repeat while "&" : enterCharacterIntoString ( !?tokenString !'&' ) while "<" : enterCharacterIntoString ( !?tokenString !'<' ) while ">" : enterCharacterIntoString ( !?tokenString !'>' ) while """ : enterCharacterIntoString ( !?tokenString !'"' ) while "'" : enterCharacterIntoString ( !?tokenString !''' ) while ~ "\"" error incorrectAttributeEnd : enterCharacterIntoString ( !?tokenString !* ) end send $value$ } rule ''' { repeat while "&" : enterCharacterIntoString ( !?tokenString !'&' ) while "<" : enterCharacterIntoString ( !?tokenString !'<' ) while ">" : enterCharacterIntoString ( !?tokenString !'>' ) while """ : enterCharacterIntoString ( !?tokenString !'"' ) while "'" : enterCharacterIntoString ( !?tokenString !''' ) while ~ "'" error incorrectAttributeEnd : enterCharacterIntoString ( !?tokenString !* ) end send $value$ } # --------------------- separators ----------------------------------------- rule '\u0001' -> ' ' { } #----------------------------------------------------------------------------* }