Class: Rucc::Lexer::Preprocessor
- Inherits:
-
Object
- Object
- Rucc::Lexer::Preprocessor
- Includes:
- Constructor, Pragma, SpecialMacro
- Defined in:
- lib/rucc/lexer/preprocessor.rb,
lib/rucc/lexer/preprocessor/pragma.rb,
lib/rucc/lexer/preprocessor/cond_incl.rb,
lib/rucc/lexer/preprocessor/constructor.rb,
lib/rucc/lexer/preprocessor/special_macro.rb
Defined Under Namespace
Modules: CondInclCtx, Constructor, Pragma, SpecialMacro Classes: CondIncl
Instance Attribute Summary collapse
-
#expr_reader ⇒ Object
writeonly
Return parsed node, only used for read_constexpr.
Instance Method Summary collapse
- #append_include_path(path) ⇒ Object
-
#initialize(impl) ⇒ Preprocessor
constructor
A new instance of Preprocessor.
- #peek_token ⇒ Token
- #read_token ⇒ Token
- #unget_token(tok) ⇒ Object
Methods included from Constructor
#copy_token, #define_obj_macro, #make_cond_incl, #make_func_macro, #make_macro_token, #make_obj_macro, #make_special_macro
Constructor Details
#initialize(impl) ⇒ Preprocessor
Returns a new instance of Preprocessor.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rucc/lexer/preprocessor.rb', line 17 def initialize(impl) @impl = impl @std_include_path = [] # preprocessor context @cond_incl_stack = [] @macros = {} @once = {} @include_guard = {} # warning context # TODO(south37) Impl warnf @enable_warning = true # Used for __DATE__ and __TIME__ @now = Time.now define_special_macros! end |
Instance Attribute Details
#expr_reader=(value) ⇒ Object (writeonly)
Return parsed node, only used for read_constexpr
38 39 40 |
# File 'lib/rucc/lexer/preprocessor.rb', line 38 def expr_reader=(value) @expr_reader = value end |
Instance Method Details
#append_include_path(path) ⇒ Object
67 68 69 |
# File 'lib/rucc/lexer/preprocessor.rb', line 67 def append_include_path(path) @std_include_path << path end |
#peek_token ⇒ Token
60 61 62 63 64 |
# File 'lib/rucc/lexer/preprocessor.rb', line 60 def peek_token r = read_token unget_token(r) r end |
#read_token ⇒ Token
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rucc/lexer/preprocessor.rb', line 41 def read_token while true tok = if tok.bol && Token.is_keyword?(tok, '#') && (tok.hideset.size == 0) read_directive(tok) next end Util.assert!{ !T::CPP_TOKENS.include?(tok.kind) } return maybe_convert_keyword(tok) end raise "Must not reach here!" end |
#unget_token(tok) ⇒ Object
55 56 57 |
# File 'lib/rucc/lexer/preprocessor.rb', line 55 def unget_token(tok) @impl.unget_token(tok) end |