# -*- coding: utf-8 -*- ## frozen_string_literal: truemoduleRougemoduleLexersclassDafny<RegexLexertitle"Dafny"desc"The Dafny programming language (github.com/dafny-lang/dafny)"tag"dafny"filenames"*.dfy"mimetypes"text/x-dafny"keywords=%w(
abstract allocated assert assume
break by
calc case class codatatype const constructor
datatype decreases downto
else ensures exists expect export extends
false for forall fresh function
ghost greatest
if import include invariant iterator
label least lemma
match method modifies modify module
nameonly new newtype null
old opened
predicate print provides
reads refines requires return returns reveal reveals
static
then this to trait true twostate type
unchanged
var
while witness
yield yields
)literals=%w{ true false null }textOperators=%w{ as is in }types=%w(bool char int real string nat
array array? object object? ORDINAL
seq set iset map imap multiset )idstart=/[0-9a-zA-Z?]/idchar=/[0-9a-zA-Z_'?]/id=/#{idstart}#{idchar}*/arrayType=/array(?:1[0-9]+|[2-9][0-9]*)\??(?!#{idchar})/bvType=/bv(?:0|[1-9][0-9]*)(?!#{idchar})/digit=/\d/digits=/#{digit}+(?:_#{digit}+)*/bin_digits=/[01]+(?:_[01]+)*/hex_digit=/(?:[0-9a-fA-F])/hex_digits=/#{hex_digit}+(?:_#{hex_digit}+)*/cchar=/(?:[^\\'\n\r]|\\["'ntr\\0])/schar=/(?:[^\\"\n\r]|\\["'ntr\\0])/uchar=/(?:\\u#{hex_digit}{4})/## IMPORTANT: Rules are ordered, which allows later rules to be ## simpler than they would otherwise bestate:rootdorule%r(/\*),Comment::Multiline,:commentrule%r(//.*?$),Comment::Singlerule%r(\*/),Error# should not have closing comment in :root# is an improperly nested commentrule%r/'#{cchar}'/,Str::Char# standard or escape charrule%r/'#{uchar}'/,Str::Char# unicode charrule%r/'[^'\n\r]*'/,Error# bad any other enclosed charrule%r/'[^'\n\r]*$/,Error# bad unclosed charrule%r/"(?:#{schar}|#{uchar})*"/,Str::Double# valid stringrule%r/".*"/,Error# anything else that is closedrule%r/".*$/,Error# bad unclosed stringrule%r/@"([^"]|"")*"/,Str::Other# valid verbatim stringrule%r/@".*/m,Error# anything else , multiline unclosedrule%r/#{digits}\.#{digits}(?!#{idchar})/,Num::Floatrule%r/0b#{bin_digits}(?!#{idchar})/,Num::Binrule%r/0b#{idchar}*/,Errorrule%r/0x#{hex_digits}(?!#{idchar})/,Num::Hexrule%r/0x#{idchar}*/,Errorrule%r/#{digits}(?!#{idchar})/,Num::Integerrule%r/_(?!#{idchar})/,Namerule%r/_[0-9_]+[_]?(?!#{idchar})/,Errorrule%r/[0-9_]+_(?!#{idchar})/,Errorrule%r/[0-9]#{idchar}+/,Errorrule%r/#{arrayType}/,Keyword::Typerule%r/#{bvType}/,Keyword::Typeruleiddo|m|iftypes.include?(m[0])tokenKeyword::Typeelsifliterals.include?(m[0])tokenKeyword::ConstantelsiftextOperators.include?(m[0])tokenOperator::Wordelsifkeywords.include?(m[0])tokenKeyword::ReservedelsetokenNameendendrule%r/\.\./,Operatorrule%r/[*!%&<>\|^+=:.\/-]/,Operatorrule%r/[\[\](){},;`]/,Punctuationrule%r/[^\S\n]+/,Textrule%r/\n/,Textrule%r/./,Error# Catchallendstate:commentdorule%r(\*/),Comment::Multiline,:pop!rule%r(/\*),Comment::Multiline,:commentrule%r([^*/]+),Comment::Multilinerule%r(.),Comment::Multilineendendendend