Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solidity highlighting #395

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions solidity.nanorc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# manually created by referencing:
# - https://github.com/solidityj/solidity-antlr4/blob/master/Solidity.g4
# - https://github.com/ConsenSysMesh/solidity-parser/blob/master/solidity.pegjs
# - https://docs.soliditylang.org/en/v0.4.24/units-and-global-variables.html


syntax "solidity" "\.sol$"

color brightmagenta "^pragma.*$"
color brightgreen "import"

# Other things
color brightcyan "using|for|modifier|if|else|while|do |assembly|continue|break|throw|emit|var|let "
color brightcyan "after|delete|switch|case|default|hex|abstract|catch|final| in |inline|match|of|relocatable|static|try|typeof|get"
color brightcyan "anonymous|constant|return |set"

# Modifiers
color brightmagenta "public|private|internal|external|pure|view|payable|override|virtual|memory|storage|calldata|indexed|type"

# Types
color green "bool|address|string|struct|enum|event|mapping"
color green "int|int8|int16|int24|int32|int40|int48|int56|int64|int72|int80|int88|int96|int104|int112|int120|int128|int136|int144|int152|int160|int168|int176|int184|int192|int200|int208|int216|int224|int232|int240|int248|int256"
color green "uint|uint8|uint16|uint24|uint32|uint40|uint48|uint56|uint64|uint72|uint80|uint88|uint96|uint104|uint112|uint120|uint128|uint136|uint144|uint152|uint160|uint168|uint176|uint184|uint192|uint200|uint208|uint216|uint224|uint232|uint240|uint248|uint256"
color green "bytes|bytes1|bytes2|bytes3|bytes4|bytes5|bytes6|bytes7|bytes8|bytes9|bytes10|bytes11|bytes12|bytes13|bytes14|bytes15|bytes16|bytes17|bytes18|bytes19|bytes20|bytes21|bytes22|bytes23|bytes24|bytes25|bytes26|bytes27|bytes28|bytes29|bytes30|bytes31|bytes32"
color green "fixed|ufixed|true|false|null"


# Units
icolor red "wei|szabo|finney|ether|seconds|days|minutes|hours|weeks|years"

# Classes
color cyan "function|class|contract|interface|library| is |as |returns|new|constructor|selfdestruct|extends|super|suicide"

# bifs
color magenta "this|now|keccak256|(abi.(\w+\.)+?\w+)|blockhash|(block.(\w+\.)+?\w+)|require|(msg.(\w+\.)+?\w+)|(tx.(\w+\.)+?\w+)"
color magenta "assert|revert|addmod|mulmod|sha256|sha3|ripemd160|ecrecover"

# address functions
color yellow "0x\w+\.(balance|transfer|send|call|callcode|delegatecall)"
color yellow "0x\w{64}"

# Comments
color blue "(^|[[:space:]])//.*$"
39 changes: 39 additions & 0 deletions zeek.nanorc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## Here is an example nanorc for syntax highlighting in Zeek scripts. Edited the standard sh.nanorc to create this, and added in the regex described by Scott Runnels.
## For Scott's bro-mode.el, go to https://github.com/srunnels/bro-mode/blob/master/bro-mode.el

syntax "zeek" "\.zeek$"
magic "(POSIX|Bourne.*) shell script text"
header "^#!.*/(ba|k|pdk)?sh[-0-9_]*"
icolor brightgreen "^[0-9A-Z_]+\(\)"

color cyan "(usec|msec|sec|min|hr|day)s?\b"
color cyan "[0-9]+\/(tcp|udp|icmp|unknown)"

# Functions and event names
color magenta "\w+\("

# Declarations and statements
color brightcyan "\<(add|alarm|fallthrough|break|case|const|copy|continue|do|delete|else|for|global|switch|default|if|endif|local|next|of|print|redef|return|schedule|type|when|while|option)\>"
color brightcyan "module|export|timeout"

# Types
color cyan "\<(addr|opaque|any|bool|hook|connection|function|count|time|double|file|int|enum|event|interval|net|port|pattern|record|set|string|subnet|table|vector)\>"

# Namespaces
color yellow "(\w+?)::\b"

# Operators
color green "(:|\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|& |&&|\||\?|%|\+|\*|-\W| as |\^|~| not | in | is | !in | : |,)"

# attributes
color brightgreen "\&(expire_func|redef|priority|log|optional|default|add_func|delete_func|read_expire|write_expire|create_expire|on_change|raw_output|error_handler|type_column|deprecated)"

# Directives and record references
icolor brightred "(@\w+)"
icolor red "(\w+?)\$\{?[0-9A-Z_!@#$*?-]+\}?"

# string literals
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"

# Comments
color blue "(^|[[:space:]])#.*$"