Skip to content

Commit

Permalink
Added disambiguation rule and tests for '*.s', '*.S'
Browse files Browse the repository at this point in the history
  • Loading branch information
mpartel committed Nov 16, 2023
1 parent cb77043 commit d128a6a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/rouge/guessers/disambiguation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ def match?(filename)
next Prolog if matches?(/\A\w+(\(\w+\,\s*\w+\))*\./)
next OpenEdge
end

disambiguate '*.s', '*.S' do
next GnuAsm if matches?(/\s*\.(global|extern|type|text)/)
next GnuAsm if matches?(/%(r|e)(ax|bx|cx|dx|si|di|bp|sp)/)

ArmAsm
end
end
end
end
14 changes: 14 additions & 0 deletions spec/lexers/armasm_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*- #
# frozen_string_literal: true

describe Rouge::Lexers::ArmAsm do
let(:subject) { Rouge::Lexers::ArmAsm.new }

describe 'guessing' do
include Support::Guessing

it 'guesses by filename and source hint' do
assert_guess :filename => 'foo.s', :source => 'Func MOVW r0, #RetVal'
end
end
end
14 changes: 14 additions & 0 deletions spec/lexers/gnuasm_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*- #
# frozen_string_literal: true

describe Rouge::Lexers::GnuAsm do
let(:subject) { Rouge::Lexers::GnuAsm.new }

describe 'guessing' do
include Support::Guessing

it 'guesses by filename and source hint' do
assert_guess :filename => 'foo.s', :source => 'main: movq %rax, %rbx'
end
end
end

0 comments on commit d128a6a

Please sign in to comment.