Method: MicroCisc::Compile::Statement#filter_comments
- Defined in:
- lib/micro_cisc/compile/statement.rb
#filter_comments(instruction) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/micro_cisc/compile/statement.rb', line 17 def filter_comments(instruction) # Remove all inline comments instruction = instruction.to_s.strip.gsub(/\/[^\/]*\//, '') # Remove all word comments instruction = instruction.gsub(/'[^\s]*/, '') # Remove all line comments instruction = instruction.gsub(/#.*/, '') # Single space instruction.gsub(/\s+/, ' ') end |