-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs-resources pdf theme, IDL highlighting (#10)
* Add riscv pdf template, IDL syntax highlighting
- Loading branch information
Showing
9 changed files
with
239 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "ext/riscv-opcodes"] | ||
path = ext/riscv-opcodes | ||
url = https://github.com/riscv/riscv-opcodes.git | ||
[submodule "ext/docs-resources"] | ||
path = ext/docs-resources | ||
url = https://github.com/riscv/docs-resources.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require "rouge" | ||
|
||
module Rouge | ||
module Lexers | ||
class Idl < RegexLexer | ||
tag "idl" | ||
filenames "idl", "isa" | ||
|
||
title "IDL" | ||
desc "ISA Description Language" | ||
|
||
ws = /[ \n]+/ | ||
id = /[a-zA-Z_][a-zA-Z0-9_]*/ | ||
|
||
def self.keywords | ||
@keywords ||= Set.new %w[ | ||
if else for return returns arguments description body function builtin enum bitfield | ||
] | ||
end | ||
|
||
def self.keywords_type | ||
@keywords_type ||= Set.new %w[ | ||
Bits XReg U32 U64 String Boolean | ||
] | ||
end | ||
|
||
# start { push :bol } | ||
|
||
state :bol do | ||
rule(//) { pop! } | ||
end | ||
|
||
state :root do | ||
rule ws, Text::Whitespace | ||
rule %r{#.*}, Comment::Single | ||
rule %r{"[^"]*"}, Str::Double | ||
rule %r{[A-Z][a-zA-Z0-9]*}, Name::Constant | ||
rule %r{(?:(?:[0-9]+)|(?:XLEN))?'s?[bodh]?[0-9_a-fA-F]+}, Num | ||
rule %r/0x[0-9a-f]+[lu]*/i, Num::Hex | ||
rule %r/0[0-7]+[lu]*/i, Num::Oct | ||
rule %r{\d+}, Num::Integer | ||
rule %r{(?:true|false|\$encoding|\$pc)}, Name::Builtin | ||
rule %r{[.,;:\[\]\(\)\}\{]}, Punctuation | ||
rule %r([~!%^&*+=\|?:<>/-]), Operator | ||
rule id do |m| | ||
name = m[0] | ||
|
||
if self.class.keywords.include? name | ||
token Keyword | ||
elsif self.class.keywords_type.include? name | ||
token Keyword::Type | ||
else | ||
token Name | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.