class Rouge::Lexers::Solidity

Public Class Methods

builtins() click to toggle source
# File lib/rouge/lexers/solidity.rb, line 32
def self.builtins
  return @builtins if @builtins

  @builtins = Set.new %w(
    now
    false true
    balance now selector super this
    blockhash gasleft
    assert require revert
    selfdestruct suicide
    call callcode delegatecall
    send transfer
    addmod ecrecover keccak256 mulmod sha256 sha3 ripemd160
  )

  # TODO: use (currently shadowed by catch-all in :statements)
  abi = %w(decode encode encodePacked encodeWithSelector encodeWithSignature)
  @builtins.merge( abi.map { |i| "abi.#{i}" } )
  block = %w(coinbase difficulty gaslimit hash number timestamp)
  @builtins.merge( block.map { |i| "block.#{i}" } )
  msg = %w(data gas sender sig value)
  @builtins.merge( msg.map { |i| "msg.#{i}" } )
  tx = %w(gasprice origin)
  @builtins.merge( tx.map { |i| "tx.#{i}" } )
end
constants() click to toggle source
# File lib/rouge/lexers/solidity.rb, line 58
def self.constants
  @constants ||= Set.new %w(
    wei finney szabo ether
    seconds minutes hours days weeks years
  )
end
detect?(text) click to toggle source
# File lib/rouge/lexers/solidity.rb, line 15
def self.detect?(text)
  return true if text.start_with? 'pragma solidity'
end
keywords() click to toggle source

TODO: seperate by “type”

# File lib/rouge/lexers/solidity.rb, line 20
def self.keywords
  @keywords ||= Set.new %w(
    abstract anonymous as assembly break catch calldata constant
    constructor continue contract do delete else emit enum event
    external fallback for function hex if indexed interface
    internal import is library mapping memory modifier new
    override payable public pure pragma private receive return
    returns storage struct throw try type using var view virtual
    while
  )
end
keywords_type() click to toggle source
# File lib/rouge/lexers/solidity.rb, line 65
def self.keywords_type
  @keywords_type ||= Set.new %w(
    address bool byte bytes int string uint
  )
end
reserved() click to toggle source
# File lib/rouge/lexers/solidity.rb, line 71
def self.reserved
  @reserved ||= Set.new %w(
    alias after apply auto case copyof default define final fixed
    immutable implements in inline let macro match mutable null of
    partial promise reference relocatable sealed sizeof static
    supports switch typedef typeof ufixed unchecked
  )
end