|
| 1 | +# Rouge lexer for FrogLang (the ProofFrog language). |
| 2 | +# |
| 3 | +# Registers the `prooffrog` tag (plus per-file-type aliases) so that fenced |
| 4 | +# code blocks like ```prooffrog are syntax-highlighted server-side by Rouge |
| 5 | +# at Jekyll build time. This replaces the previous client-side Prism setup. |
| 6 | +# |
| 7 | +# The token set mirrors the old Prism grammar in assets/js/prism-prooffrog.js. |
| 8 | + |
| 9 | +require 'rouge' |
| 10 | + |
| 11 | +module Rouge |
| 12 | + module Lexers |
| 13 | + class ProofFrog < Rouge::RegexLexer |
| 14 | + title 'ProofFrog' |
| 15 | + desc 'FrogLang, the language of the ProofFrog proof assistant' |
| 16 | + tag 'prooffrog' |
| 17 | + aliases 'froglang', 'primitive', 'scheme', 'game', 'proof' |
| 18 | + filenames '*.primitive', '*.scheme', '*.game', '*.proof' |
| 19 | + |
| 20 | + # Top-level construct introducers |
| 21 | + declarations = %w[Primitive Scheme Game Reduction Phase] |
| 22 | + |
| 23 | + # Built-in types |
| 24 | + builtins = %w[Bool Void Int BitString Set Map Array] |
| 25 | + |
| 26 | + # Reserved words |
| 27 | + keywords = %w[ |
| 28 | + import export as extends compose against requires |
| 29 | + if else for return in to |
| 30 | + union subsets induction from calls |
| 31 | + Adversary oracles proof |
| 32 | + let assume theorem games |
| 33 | + ] |
| 34 | + |
| 35 | + state :root do |
| 36 | + rule %r(\s+), Text |
| 37 | + rule %r(//.*), Comment::Single |
| 38 | + |
| 39 | + # Single-quoted import path strings |
| 40 | + rule %r('[^']*'), Str::Single |
| 41 | + |
| 42 | + # Numbers: binary literals and decimal integers |
| 43 | + rule %r(\b0b[01]+\b), Num::Bin |
| 44 | + rule %r(\b\d+\b), Num::Integer |
| 45 | + |
| 46 | + # None / true / false |
| 47 | + rule %r(\bNone\b), Keyword::Constant |
| 48 | + rule %r(\b(?:true|false)\b), Keyword::Constant |
| 49 | + |
| 50 | + rule %r(\b(?:#{builtins.join('|')})\b), Name::Builtin |
| 51 | + rule %r(\b(?:#{declarations.join('|')})\b), Keyword::Declaration |
| 52 | + rule %r(\b(?:#{keywords.join('|')})\b), Keyword |
| 53 | + |
| 54 | + # Operators (longest match first) |
| 55 | + rule %r(<-|[=!<>]=|&&|\|\|), Operator |
| 56 | + rule %r([+\-*/\\|!<>=]), Operator |
| 57 | + |
| 58 | + rule %r([{}\[\]();:,.?]), Punctuation |
| 59 | + |
| 60 | + rule %r(\w+), Name |
| 61 | + rule %r(.), Text |
| 62 | + end |
| 63 | + end |
| 64 | + end |
| 65 | +end |
0 commit comments