Class: SystemRDL::Parser::Scanner
- Inherits:
-
Object
- Object
- SystemRDL::Parser::Scanner
- Includes:
- RaiseParseError
- Defined in:
- lib/systemrdl/parser/scanner.rb
Constant Summary collapse
- WHITE_SPACES =
/[ \t\n\r]+/- LINE_COMMENT =
%r{//.*$}- BLOCK_COMMENT =
%r{/\*(?:(?!\*/).)*\*/}m- UNTERMINATED_BLOCK_COMMENT =
%r{/\*(?:(?!\*/).)*}m- KEYWORDS =
keyword_patterns- SYMBOLS =
symbol_patterns- VERILOG_BIN_NUMBER =
/(\d+)'[bB]([01][01_]*)/- VERILOG_DEC_NUMBER =
/(\d+)'[dD](\d[\d_]*)/- VERILOG_HEX_NUMBER =
/(\d+)'[hH](\h[\h_]*)/- DEC_NUMBER =
/\d[\d_]*/- HEX_NUMBER =
/0[xX]\h[\h_]*/- NUMBERS =
{ VERILOG_HEX_NUMBER => :VERILOG_NUMBER, VERILOG_DEC_NUMBER => :VERILOG_NUMBER, VERILOG_BIN_NUMBER => :VERILOG_NUMBER, HEX_NUMBER => :NUMBER, DEC_NUMBER => :NUMBER }.freeze
Instance Method Summary collapse
-
#initialize(code, filename, test) ⇒ Scanner
constructor
A new instance of Scanner.
- #next_token ⇒ Object
Constructor Details
#initialize(code, filename, test) ⇒ Scanner
Returns a new instance of Scanner.
69 70 71 72 73 74 75 76 |
# File 'lib/systemrdl/parser/scanner.rb', line 69 def initialize(code, filename, test) @ss = StringScanner.new(code) @filename = filename @line = 1 @column = 1 @control_tokens = [] @control_tokens << create_test_token(test) if test end |
Instance Method Details
#next_token ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/systemrdl/parser/scanner.rb', line 78 def next_token if @control_tokens.empty? skip_blank push_eos_tokens if eos? end token = if @control_tokens.empty? scan_next_token else @control_tokens.shift end token && [token.kind, token] end |