Class: ZOMG::IDL::Parser
- Inherits:
-
Lexer
- Object
- Racc::Parser
- Lexer
- ZOMG::IDL::Parser
show all
- Defined in:
- lib/zomg/idl/parser.rb
Constant Summary
Constants inherited
from Lexer
Lexer::Racc_arg, Lexer::Racc_debug_parser, Lexer::Racc_token_to_s_table
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Lexer
#_reduce_none
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
14
15
16
17
|
# File 'lib/zomg/idl/parser.rb', line 14
def initialize
@scanner = Scanner.new
@yydebug = false
end
|
Class Method Details
.parse(string) ⇒ Object
9
10
11
|
# File 'lib/zomg/idl/parser.rb', line 9
def parse(string)
new.parse(string)
end
|
.parse_file(filename) ⇒ Object
5
6
7
|
# File 'lib/zomg/idl/parser.rb', line 5
def parse_file(filename)
new.parse_file(filename)
end
|
Instance Method Details
#next_token ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/zomg/idl/parser.rb', line 38
def next_token
token = @scanner.next_token
return [false, false] unless token
token = next_token() if token[0] == :T_COMMENT
token = next_token() if token[0] == :T_PREPROCESSOR
token = next_token() if token[0] == :T_PRAGMA
token
end
|
#on_error(error_token_id, error_value, value_stack) ⇒ Object
47
48
49
50
51
|
# File 'lib/zomg/idl/parser.rb', line 47
def on_error(error_token_id, error_value, value_stack)
puts token_to_str(error_token_id)
puts error_value
p value_stack.last
end
|
#parse(contents) ⇒ Object
20
21
22
23
|
# File 'lib/zomg/idl/parser.rb', line 20
def parse(contents)
@scanner.scan_evaluate(contents)
do_parse
end
|
#parse_file(filename) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/zomg/idl/parser.rb', line 25
def parse_file(filename)
contents = File.read(filename)
if contents =~ /^\s*#/
dir = File.dirname(File.expand_path(filename))
contents = IO.popen("gcc -E -I #{dir} -I . -", 'w+') { |io|
io.write(contents)
io.close_write
io.read
}
end
parse(contents)
end
|