Class: ImgToScript::Languages::MK90Basic::MK90BasicToken

Inherits:
ImgToScript::LanguageToken show all
Defined in:
lib/img_to_script/languages/mk90_basic/mk90_basic_token.rb

Overview

Designed to be used with the MK90 BASIC translator & formatter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyword:, args:, separator:, require_nl:, sliceable:) ⇒ MK90BasicToken

Initialize a new BASIC token.

sliceable = true:
                            | <- max. characters per line limit
 10 DATA 1, [omitted...], 8, 9, 10, 11
    =>                      |
 10 DATA 1, [omitted...], 8
 20 DATA 9, 10, 11          |

sliceable = false:
                            |
 10 [omitted...]:PRINT"HELLO, WORLD!"
    =>                      |
 10 [omitted...]            |
 20 PRINT"HELLO, WORLD!"    |

Parameters:

  • keyword (String)

    Statement keyword (e.g.: “PRINT”, “FOR”, “CLS”).

  • args (Array<Numeric, String>)

    Statement arguments (e.g.: %i[10 20 30 40]).

  • separator (String)

    Separator between arguments. Commonly a comma or an ‘empty’ string (no separation between arguments).

  • require_nl (Boolean)

    Defines if the statement should be placed on a new line.

  • sliceable (Boolean)

    Defines if the statement allows to ‘slice’ its arguments, to move some of them on a new line if the expression doesn’t fit into a current line. Examples:



47
48
49
50
51
52
53
54
55
# File 'lib/img_to_script/languages/mk90_basic/mk90_basic_token.rb', line 47

def initialize(keyword:, args:, separator:, require_nl:, sliceable:)
  @keyword = keyword
  @args = args
  @separator = separator
  @require_nl = require_nl
  @sliceable = sliceable

  super()
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



10
11
12
# File 'lib/img_to_script/languages/mk90_basic/mk90_basic_token.rb', line 10

def args
  @args
end

#keywordObject

Returns the value of attribute keyword.



10
11
12
# File 'lib/img_to_script/languages/mk90_basic/mk90_basic_token.rb', line 10

def keyword
  @keyword
end

#require_nlObject

Returns the value of attribute require_nl.



10
11
12
# File 'lib/img_to_script/languages/mk90_basic/mk90_basic_token.rb', line 10

def require_nl
  @require_nl
end

#separatorObject

Returns the value of attribute separator.



10
11
12
# File 'lib/img_to_script/languages/mk90_basic/mk90_basic_token.rb', line 10

def separator
  @separator
end

#sliceableObject

Returns the value of attribute sliceable.



10
11
12
# File 'lib/img_to_script/languages/mk90_basic/mk90_basic_token.rb', line 10

def sliceable
  @sliceable
end