Module: Rucc::Lexer::Preprocessor::Constructor

Included in:
Rucc::Lexer::Preprocessor
Defined in:
lib/rucc/lexer/preprocessor/constructor.rb

Instance Method Summary collapse

Instance Method Details

#copy_token(tok) ⇒ Token

Parameters:

Returns:



48
49
50
# File 'lib/rucc/lexer/preprocessor/constructor.rb', line 48

def copy_token(tok)
  tok.dup
end

#define_obj_macro(name, value) ⇒ Object

Parameters:

  • name (String)
  • value (Token)


7
8
9
# File 'lib/rucc/lexer/preprocessor/constructor.rb', line 7

def define_obj_macro(name, value)
  @macros[name] = make_obj_macro([value])
end

#make_cond_incl(wastrue) ⇒ Object

Parameters:

  • wastrue (Boolean)


30
31
32
# File 'lib/rucc/lexer/preprocessor/constructor.rb', line 30

def make_cond_incl(wastrue)
  CondIncl.new(CondInclCtx::THEN, wastrue: wastrue)
end

#make_func_macro(body, nargs, is_varg) ⇒ Object

Parameters:

  • body (<Token>)
  • nargs (Integer)
  • is_varg (Boolean)


20
21
22
# File 'lib/rucc/lexer/preprocessor/constructor.rb', line 20

def make_func_macro(body, nargs, is_varg)
  Macro.new(M::FUNC, body: body, nargs: nargs, is_varg: is_varg)
end

#make_macro_token(position, is_vararg) ⇒ Object

Parameters:

  • position (Integer)
  • is_vararg (Boolean)


36
37
38
39
40
41
42
43
44
# File 'lib/rucc/lexer/preprocessor/constructor.rb', line 36

def make_macro_token(position, is_vararg)
  Token.new(T::MACRO_PARAM,
            is_vararg: is_vararg,
            hideset: nil,
            position: position,
            space: false,
            bol: false,
           )
end

#make_obj_macro(body) ⇒ Macro

Parameters:

Returns:



13
14
15
# File 'lib/rucc/lexer/preprocessor/constructor.rb', line 13

def make_obj_macro(body)
  Macro.new(M::OBJ, body: body)
end

#make_special_macro(fn) ⇒ Object

Parameters:

  • fn (Proc)


25
26
27
# File 'lib/rucc/lexer/preprocessor/constructor.rb', line 25

def make_special_macro(fn)
  Macro.new(M::SPECIAL, fn: fn)
end