class ADSL::Parser::ADSLParser
Constants
- Racc_arg
- Racc_debug_parser
- Racc_token_to_s_table
Attributes
filename[R]
lineno[R]
state[RW]
Public Instance Methods
_next_token()
click to toggle source
# File lib/adsl/parser/adsl_parser.rex.rb, line 56 def _next_token text = @ss.peek(1) @lineno += 1 if text == "\n" token = case @state when nil case when (text = @ss.scan(/\/\/[^\n\z]*/)) ; when (text = @ss.scan(/\#[^\n\z]*/)) ; when (text = @ss.scan(/\/\*(?:[^\*]*(?:\*+[^\/]+)?)*\*\//)) ; when (text = @ss.scan(/class\b/)) action { [:class, lineno] } when (text = @ss.scan(/extends\b/)) action { [:extends, lineno] } when (text = @ss.scan(/inverseof\b/)) action { [:inverseof, lineno] } when (text = @ss.scan(/create\b/)) action { [:create, lineno] } when (text = @ss.scan(/delete\b/)) action { [:delete, lineno] } when (text = @ss.scan(/foreach\b/)) action { [:foreach, lineno] } when (text = @ss.scan(/either\b/)) action { [:either, lineno] } when (text = @ss.scan(/action\b/)) action { [:action, lineno] } when (text = @ss.scan(/or\b/)) action { [:or, lineno] } when (text = @ss.scan(/subset\b/)) action { [:subset, lineno] } when (text = @ss.scan(/oneof\b/)) action { [:oneof, lineno] } when (text = @ss.scan(/allof\b/)) action { [:allof, lineno] } when (text = @ss.scan(/forall\b/)) action { [:forall, lineno] } when (text = @ss.scan(/exists\b/)) action { [:exists, lineno] } when (text = @ss.scan(/in\b/)) action { [:in, lineno] } when (text = @ss.scan(/invariant\b/)) action { [:invariant, lineno] } when (text = @ss.scan(/true\b/)) action { [:true, lineno] } when (text = @ss.scan(/false\b/)) action { [:false, lineno] } when (text = @ss.scan(/!=/)) action { [text, lineno] } when (text = @ss.scan(/!|not\b/)) action { [:not, lineno] } when (text = @ss.scan(/and\b/)) action { [:and, lineno] } when (text = @ss.scan(/equal\b/)) action { [:equal, lineno] } when (text = @ss.scan(/equiv\b/)) action { [:equiv, lineno] } when (text = @ss.scan(/empty\b/)) action { [:empty, lineno] } when (text = @ss.scan(/implies\b/)) action { [:implies, lineno] } when (text = @ss.scan(/\.\./)) action { [text, lineno] } when (text = @ss.scan(/[{}:\(\)\.,]/)) action { [text, lineno] } when (text = @ss.scan(/\+=/)) action { [text, lineno] } when (text = @ss.scan(/\-=/)) action { [text, lineno] } when (text = @ss.scan(/==/)) action { [text, lineno] } when (text = @ss.scan(/<=>/)) action { [text, lineno] } when (text = @ss.scan(/<=/)) action { [text, lineno] } when (text = @ss.scan(/=>/)) action { [text, lineno] } when (text = @ss.scan(/=/)) action { [text, lineno] } when (text = @ss.scan(/\+/)) action { [text, lineno] } when (text = @ss.scan(/[01]/)) action { [text, lineno] } when (text = @ss.scan(/\w+/)) action { [:IDENT, ADSL::Parser::ASTIdent.new(:lineno => lineno, :text => text)] } when (text = @ss.scan(/\s/)) ; when (text = @ss.scan(/./)) action { [:unknown_symbol, [text, lineno]] } else text = @ss.string[@ss.pos .. -1] raise ScanError, "can not match: '" + text + "'" end # if else raise ScanError, "undefined state: '" + state.to_s + "'" end # case state token end
_reduce_none(val, _values, result)
click to toggle source
# File lib/adsl/parser/adsl_parser.tab.rb, line 1023 def _reduce_none(val, _values, result) val[0] end
action() { || ... }
click to toggle source
# File lib/adsl/parser/adsl_parser.rex.rb, line 25 def action yield end
load_file( filename )
click to toggle source
# File lib/adsl/parser/adsl_parser.rex.rb, line 35 def load_file( filename ) @filename = filename open(filename, "r") do |f| scan_setup(f.read) end end
next_token()
click to toggle source
# File lib/adsl/parser/adsl_parser.rex.rb, line 48 def next_token return if @ss.eos? # skips empty actions until token = _next_token or @ss.eos?; end token end
scan_file( filename )
click to toggle source
# File lib/adsl/parser/adsl_parser.rex.rb, line 42 def scan_file( filename ) load_file(filename) do_parse end
scan_setup(str)
click to toggle source
# File lib/adsl/parser/adsl_parser.rex.rb, line 19 def scan_setup(str) @ss = StringScanner.new(str) @lineno = 1 @state = nil end
scan_str(str)
click to toggle source
# File lib/adsl/parser/adsl_parser.rex.rb, line 29 def scan_str(str) scan_setup(str) do_parse end
Also aliased as: scan