aboutsummaryrefslogtreecommitdiffstats
path: root/docs/util
diff options
context:
space:
mode:
authorKrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com>2022-11-16 00:55:22 +1300
committerGitHub <noreply@github.com>2022-11-15 12:55:22 +0100
commita14dec79ebc85fae807684fa027d8098a16a4d34 (patch)
treef05562ce671f452f6d29a90219cced0b37c1aae4 /docs/util
parent853f4bb3c695d9f5183ef5064ec4cf9cdd8b5300 (diff)
downloadyosys-a14dec79ebc85fae807684fa027d8098a16a4d34.tar.gz
yosys-a14dec79ebc85fae807684fa027d8098a16a4d34.tar.bz2
yosys-a14dec79ebc85fae807684fa027d8098a16a4d34.zip
Rst docs conversion (#3496)
Rst docs conversion
Diffstat (limited to 'docs/util')
-rw-r--r--docs/util/RtlilLexer.py45
-rw-r--r--docs/util/YoscryptLexer.py73
2 files changed, 118 insertions, 0 deletions
diff --git a/docs/util/RtlilLexer.py b/docs/util/RtlilLexer.py
new file mode 100644
index 000000000..75aa53ec8
--- /dev/null
+++ b/docs/util/RtlilLexer.py
@@ -0,0 +1,45 @@
+from pygments.lexer import RegexLexer, bygroups, include
+from pygments.token import Comment, Keyword, Name, Number, String, Whitespace
+
+__all__ = ['RtlilLexer']
+
+class RtlilLexer(RegexLexer):
+ name = 'RTLIL'
+ aliases = ['rtlil']
+ filenames = ['*.il']
+
+ keyword_re = r'(always|assign|attribute|autoidx|case|cell|connect|edge|end|global|high|init|inout|input|low|memory|module|negedge|offset|output|parameter|posedge|process|real|signed|size|switch|sync|update|upto|width|wire)'
+
+ tokens = {
+ 'common': [
+ (r'\s+', Whitespace),
+ (r'#.*', Comment.Single),
+ (keyword_re, Keyword),
+ (r'([\\\$][^ \t\r\n]+|\.[0-9]+)', Name.Variable),
+ (r"[0-9]+'[01xzm-]*", Number),
+ (r'-?[0-9]+', Number.Integer),
+ (r'"', String, 'string'),
+ ],
+ 'root': [
+ (r'cell', Keyword, 'cell_definition'),
+ (r'(module|wire|memory|process)', Keyword, 'definition'),
+ include('common'),
+ ],
+ 'definition': [
+ (r'([\\\$][^ \t\r\n]+|\.[0-9]+)', Name.Entity, '#pop'),
+ include('common')
+ ],
+ 'cell_definition': [
+ (r'(\$[^ \t\r\n]+)\b', Name.Function),
+ (r'(\\[^ \t\r\n]+|\.[0-9]+)', Name.Variable),
+ (r'$', Whitespace, '#pop'),
+ include('common'),
+ ],
+ 'string': [
+ (r'"', String, '#pop'),
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
+ (r'[^\\"\n]+', String), # all other characters
+ (r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation
+ (r'\\', String), # stray backslash
+ ]
+ }
diff --git a/docs/util/YoscryptLexer.py b/docs/util/YoscryptLexer.py
new file mode 100644
index 000000000..8cb31c81a
--- /dev/null
+++ b/docs/util/YoscryptLexer.py
@@ -0,0 +1,73 @@
+from pygments.lexer import RegexLexer, bygroups, include
+from pygments.token import (Comment, Error, Keyword, Name, Number, Operator,
+ String, Whitespace)
+
+__all__ = ['YoscryptLexer']
+
+class YoscryptLexer(RegexLexer):
+ name = 'Yosys Script'
+ aliases = ['yoscrypt']
+ filenames = ['*.ys']
+
+
+
+ tokens = {
+ 'common': [
+ (r'\s+', Whitespace),
+ (r'#.*', Comment.Single),
+ (r'"', String, 'string'),
+ (r'(\d+)(\')([bdho]? ?\w+)', bygroups(Number, Operator, Number)),
+ (r'(\d+\.\d+)', Number.Float),
+ (r'(\d+)', Number),
+ (r'(\$[A-Za-z_0-9]*)', Name.Builtin),
+ (r'([A-Za-z_][A-Za-z_0-9\.\\/:-]*)', Name),
+ (r'(\[)(-\S*)(\])', # optional command
+ bygroups(Operator, Name.Attribute, Operator)),
+ (r'([\[<]\w*[\]>])', Name), # arguments
+ (r'[\{\}\|=\[\],]', Operator),
+ (r'.', Comment),
+ ],
+ 'root': [
+ (r'([A-Za-z_][A-Za-z_0-9]*)', Keyword, 'command'),
+ (r'(-[A-Za-z_][A-Za-z_0-9]*)', Name.Attribute, 'command'), # shortcut for options
+ include('common'),
+ ],
+ 'command': [
+ (r'(-[A-Za-z_][A-Za-z_0-9]*)', Name.Attribute),
+ (r'\+/[^\s]+', Name.Class),
+ (r'$', Whitespace, '#pop'),
+ (r';(?=\s)', Operator, '#pop'),
+ (r';{2,3}(?=\s)', Name.Class, '#pop'),
+ (r';{1,3}', Error, '#pop'),
+ (r'([ANwismctparn]:)', Keyword.Type, 'pattern'),
+ (r'@', Keyword.Type),
+ (r'%(x|ci|co)e?', Keyword.Type, 'expansion'),
+ (r'%[%nuidDcasmMCR]?', Keyword.Type),
+ (r'/', Operator),
+ include('common'),
+ ],
+ 'pattern': [
+ (r'<<', Name), # Not an operator
+ (r'(=|<|<=|>|>=)', Operator),
+ (r':', Keyword.Type),
+ (r'$', Whitespace, '#pop:2'),
+ (r'\s+', Whitespace, '#pop'),
+ include('common'),
+ ],
+ 'expansion': [
+ (r'$', Name.Class, '#pop:2'),
+ (r';(?=\s)', Operator, '#pop:2'),
+ (r';{2,3}(?=\s)', Name.Class, '#pop:2'),
+ (r'\s', Whitespace, '#pop'),
+ (r'[0-9\*]{1,3}', Number),
+ (r'[:+-,\[\]]', Operator),
+ include('common'),
+ ],
+ 'string': [
+ (r'"', String, '#pop'),
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
+ (r'[^\\"\n]+', String), # all other characters
+ (r'(\\)(\n)', bygroups(String.Escape, Whitespace)), # line continuation
+ (r'\\', String), # stray backslash
+ ]
+ }