2004-09-12 17:34:30 +00:00
|
|
|
#
|
|
|
|
# ripper.rb
|
|
|
|
#
|
|
|
|
# Copyright (C) 2003,2004 Minero Aoki
|
|
|
|
#
|
|
|
|
|
|
|
|
require 'ripper.so'
|
|
|
|
|
|
|
|
class Ripper
|
2004-09-19 19:49:56 +00:00
|
|
|
# Parses Ruby program read from _src_.
|
|
|
|
# _src_ must be a String or a IO or a object which has #gets method.
|
|
|
|
def Ripper.parse(src, filename = '(ripper)', lineno = 1)
|
|
|
|
new(src, filename, lineno).parse
|
2004-09-12 17:34:30 +00:00
|
|
|
end
|
|
|
|
|
2004-09-19 19:49:56 +00:00
|
|
|
# This table contains name of parser events and its arity.
|
|
|
|
PARSER_EVENT_TABLE = {
|
|
|
|
#include ids1
|
|
|
|
}
|
|
|
|
|
|
|
|
# This array contains name of parser events.
|
|
|
|
PARSER_EVENTS = PARSER_EVENT_TABLE.keys
|
|
|
|
|
|
|
|
# This table contains name of scanner events and its arity
|
|
|
|
# (arity is always 1 for all scanner events).
|
|
|
|
# on__scan is NOT a scanner event.
|
|
|
|
SCANNER_EVENT_TABLE = {
|
|
|
|
#include ids2
|
|
|
|
}
|
|
|
|
|
|
|
|
# This array contains name of scanner events.
|
|
|
|
SCANNER_EVENTS = SCANNER_EVENT_TABLE.keys
|
|
|
|
|
|
|
|
# This table contains name of all ripper events, except on__scan.
|
|
|
|
EVENTS = PARSER_EVENTS + SCANNER_EVENTS
|
|
|
|
|
|
|
|
### ###
|
|
|
|
### Event Handlers ###
|
|
|
|
### ###
|
|
|
|
|
2004-09-12 17:34:30 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def warn(fmt, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def warning(fmt, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def compile_error(msg)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Parser Events
|
|
|
|
#
|
|
|
|
#include handlers1
|
|
|
|
|
|
|
|
#
|
|
|
|
# Lexer Events
|
|
|
|
#
|
|
|
|
|
|
|
|
def on__scan(event, token)
|
|
|
|
end
|
|
|
|
#include handlers2
|
|
|
|
end
|