summaryrefslogtreecommitdiff
path: root/ext/ripper/lib/ripper/core.rb.in
blob: 5f46c581906eb4cd047183c7141dce6d343c07e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# ripper/core.rb
#
# Copyright (C) 2003-2005 Minero Aoki
#
# This program is free software.
# You can distribute and/or modify this program under the Ruby License.
# For details of Ruby License, see ruby/COPYING.
#

require 'ripper.so'

class Ripper
  # 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
  end

  # 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).
  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.
  EVENTS = PARSER_EVENTS + SCANNER_EVENTS

  ###                ###
  ### Event Handlers ###
  ###                ###

  private

  # This method is called when weak warning is produced by the parser.
  # _fmt_ and _args_ is printf style.
  def warn(fmt, *args)
  end

  # This method is called when strong warning is produced by the parser.
  # _fmt_ and _args_ is printf style.
  def warning(fmt, *args)
  end

  # This method is called when the parser found syntax error.
  def compile_error(msg)
  end

  #
  # Parser Events
  #
#include handlers1

  #
  # Lexer Events
  #
#include handlers2
end