# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Lexers load_lexer 'xpath.rb' class XQuery < XPath title 'XQuery' desc 'XQuery 3.1: An XML Query Language' tag 'xquery' filenames '*.xquery', '*.xq' mimetypes 'application/xquery' def self.keywords @keywords ||= Regexp.union super, Regexp.union(%w( xquery encoding version declare module namespace copy-namespaces boundary-space construction default collation base-uri preserve strip ordering ordered unordered order empty greatest least preserve no-preserve inherit no-inherit decimal-format decimal-separator grouping-separator infinity minus-sign NaN percent per-mille zero-digit digit pattern-separator exponent-separator import schema at element option function external context item typeswitch switch case try catch validate lax strict type document element attribute text comment processing-instruction for let where order group by return allowing tumbling stable sliding window start end only when previous next count collation ascending descending )) end # Mixin states: state :tags do rule %r/<#{XPath.qName}/, Name::Tag, :start_tag rule %r//, Comment, :pop! rule %r/-/, Comment end state :start_tag do rule %r/\s+/m, Text::Whitespace rule %r/([\w.:-]+\s*=)(")/m do groups Name::Attribute, Str push :quot_attr end rule %r/([\w.:-]+\s*=)(')/m do groups Name::Attribute, Str push :apos_attr end rule %r/>/, Name::Tag, :tag_content rule %r(/>), Name::Tag, :pop! end state :quot_attr do rule %r/"/, Str, :pop! rule %r/\{\{/, Str rule %r/\{/, Punctuation, :root rule %r/[^"{>]+/m, Str end state :apos_attr do rule %r/'/, Str, :pop! rule %r/\{\{/, Str rule %r/\{/, Punctuation, :root rule %r/[^'{>]+/m, Str end state :tag_content do rule %r/\s+/m, Text::Whitespace mixin :tags rule %r/(\{\{|\}\})/, Text rule %r/\{/, Punctuation, :root rule %r/[^{}<&]/, Text rule %r() do token Name::Tag pop! 2 # pop self and tag_start end end end end end