Method: Syntax::Fortran#step

Defined in:
lib/syntax/lang/fortran.rb

#stepObject

Step through a single iteration of the tokenization process.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/syntax/lang/fortran.rb', line 90

def step
  case
  when check( /program\s+/ )
    start_group :keyword, scan( /program\s+/ )
    start_group :function,  scan_until( /(?=[;(\s]|#{EOL})/ )
  when check( /subroutine\s+/ )
    start_group :keyword, scan( /subroutine\s+/ )
    start_group :function,  scan_until( /(?=[;(\s]|#{EOL})/ )
  when check( /function\s+/ )
    start_group :keyword, scan( /function\s+/ )
    start_group :function,  scan_until( /(?=[;(\s]|#{EOL})/ )
  when check( /module\s+/ )
    start_group :keyword, scan( /module\s+/ )
    start_group :function,  scan_until( /(?=[;\s]|#{EOL})/ )
  when check( /\.true\.|\.false\.|\.TRUE\.|\.FALSE\./ )
    start_group :constant,
    scan(/\.true\.|\.false\.|\.TRUE\.|\.FALSE\./)
  when scan( /(\d+\.?\d*|\d*\.?\d+)([eEdDqQ][+-]?\d+)?(_\w+)?/ )
    start_group :number, matched
  when scan( /[bB]\'[01]+\'|[oO]\'[0-7]+\'|[zZ]\'[0-9a-fA-F]+\'/ )
    start_group :number, matched
  else
    case peek(1)
    when /[\n\r]/
      start_group :normal, scan( /\s+/ )
    when /\s/
      start_group :normal, scan( /\s+/ )
    when "!"
      start_group :comment, scan( /![^\n\r]*/ )
    when /[A-Za-z]/
      word = scan( /\w+/ )
      if KEYWORDS.include?(word)
        start_group :keyword, word
      elsif TYPES.include?(word)
        start_group :type, word
      elsif INTRINSICS.include?(word)
        start_group :function, word
      elsif
        start_group :ident, word
      end
    when '"'
      # allow for continuation characters within strings
      start_group :string, scan(/"([^"]*(&[ ]*[\n\r]+)?)*"/)
    when "'"
      # allow for continuation characters within strings
      start_group :string, scan(/'([^']*(&[ ]*[\n\r]+)?)*'/)
    when /[-!?*\/+=<>()\[\]\{}:;,&|%]/
      start_group :punct, scan(/./)
    else
      # pass everything else through
      append getch
    end
  end
end