# File convertdb.rb, line 282
def parseSynsetLine( string, lineNumber, pos )
        $scanner.string = string
        
        filenum, synsetType, gloss = nil, nil, nil
        words = []
        ptrs = []
        frames = []

        # Parse the first part of the synset
        $scanner.scan( Synset ) or raise "unable to parse synset"
        offset, filenum, synsetType, wordCount =
                $scanner[1], $scanner[2], $scanner[3], $scanner[4]

        # Parse the words
        wordCount.to_i(16).times do |i|
                $scanner.scan( SynWord ) or raise "unable to parse word #{i}"
                word, lexid = $scanner[1], $scanner[2]
                senseKey = (offset + "%" + pos + "%" + word).downcase
                if !$senseIndex.key?( senseKey )
                        newKey = senseKey.sub( /\(\w+\)$/, '' )
                        if !$senseIndex.key?( newKey )
                                raise "Sense index does not contain sense '#{senseKey}' "\
                                        "(tried #{newKey}, too)."
                        end
                        senseKey = newKey
                end

                words.push( word + "%" + $senseIndex[senseKey].to_s )
        end
        
        # Parse pointers
        if $scanner.scan( SynPtrCnt )
                $scanner[1].to_i.times do |i|
                        $scanner.scan( SynPtr ) or raise "unable to parse synptr #{i}"
                        ptrs.push "%s %s%%%s %s" % [
                                $scanner[1],
                                $scanner[2],
                                $scanner[3],
                                $scanner[4],
                        ]
                end
        else
                raise "Couldn't parse pointer count"
        end

        # Parse frames if this synset is a verb
        if synsetType == WordNet::Verb
                if $scanner.scan( SynFrameCnt )
                        $scanner[1].to_i.times do |i|
                                $scanner.scan( SynFrame ) or raise "unable to parse frame #{i}"
                                frames.push "#{$scanner[1]} #{$scanner[2]}"
                        end
                else
                        raise "Couldn't parse frame count"
                end
        end

        # Find the gloss
        if $scanner.scan( SynGloss )
                gloss = $scanner[1].strip
        end

        # This should never happen, as the gloss matches pretty much anything to
        # the end of line.
        if !$scanner.empty?
                raise "Trailing miscellaneous found at end of entry"
        end

        # Build the synset entry and return it
        synsetType = WordNet::Adjective if synsetType == WordNet::Other
        key = [ offset, synsetType ].join("%")
        data = [
                filenum,
                words.join( WordNet::SubDelim ),
                ptrs.join( WordNet::SubDelim ),
                frames.join( WordNet::SubDelim ),
                gloss,
        ].join( WordNet::Delim )

        return key, data
rescue => err
        message "Synset did not parse: %s at '%s...' (pos = %s, line %d)\n\t%s\n" % [
                err.message,
                $scanner.rest[0,20],
                pos.inspect,
                lineNumber,
                err.backtrace[0]
        ]
        return nil
end