class Z3::ModelParser
Constants
- Racc_arg
- Racc_debug_parser
- Racc_token_to_s_table
Attributes
filename[R]
lineno[R]
Public Instance Methods
_reduce_none(val, _values)
click to toggle source
reduce 14 omitted
# File lib/z3/model_parser.tab.rb, line 205 def _reduce_none(val, _values) val[0] end
action() { || ... }
click to toggle source
# File lib/z3/model_parser.rex.rb, line 19 def action &block yield end
load_file( filename )
click to toggle source
# File lib/z3/model_parser.rex.rb, line 28 def load_file( filename ) @filename = filename open(filename, "r") do |f| scan_evaluate f.read end end
next_token()
click to toggle source
# File lib/z3/model_parser.rex.rb, line 40 def next_token @rex_tokens.shift end
scan_evaluate( str )
click to toggle source
# File lib/z3/model_parser.rex.rb, line 44 def scan_evaluate( str ) scan_setup @rex_tokens = [] @lineno = 1 ss = StringScanner.new(str) state = nil until ss.eos? text = ss.peek(1) @lineno += 1 if text == "\n" case state when nil case when (text = ss.scan(/\*\*\*.*(?=\n)/)) ; when (text = ss.scan(/\s+/)) ; when (text = ss.scan(/->|-|\(|\)/)) @rex_tokens.push action { [text, text] } when (text = ss.scan(/\d+/)) @rex_tokens.push action { [:NUMBER, text.to_i] } when (text = ss.scan(/true|false/)) @rex_tokens.push action { [:BOOLEAN, eval(text)] } when (text = ss.scan(/\b(else)\b/)) @rex_tokens.push action { [text, text] } when (text = ss.scan(/[a-zA-Z_.$\#'`~^\\?!@%-\[\]][\w.$\#'`~^\\?!@%-\[\]]*/)) @rex_tokens.push action { [:SYMBOL, text.to_sym] } when (text = ss.scan(/./)) @rex_tokens.push action { [text, text] } 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 end # until ss end
scan_file( filename )
click to toggle source
# File lib/z3/model_parser.rex.rb, line 35 def scan_file( filename ) load_file filename do_parse end
scan_setup()
click to toggle source
# File lib/z3/model_parser.rex.rb, line 17 def scan_setup ; end
scan_str( str )
click to toggle source
# File lib/z3/model_parser.rex.rb, line 23 def scan_str( str ) scan_evaluate str do_parse end