rips 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdcd7ac5e84f05fc158a28a566929b6d3251c258
4
- data.tar.gz: e4f4beb9654c63df7c3511ba444a6aa34412a85b
3
+ metadata.gz: 15d47ea6c151a478f9748664cb04398ef56a6c25
4
+ data.tar.gz: 0bca77b30fa8ab05d24f04dbeb0459ba0ba8b790
5
5
  SHA512:
6
- metadata.gz: 98e4986808fdc90758b8cb9655d53f55292c84fb2cd2ebdecd130f616a6c7614c5e5ad2ced47a986d6c876e815d87cd5653ef421b7d8f96022e7e2a4d9e1b4b2
7
- data.tar.gz: 8098fb8dfb1bb2f4aa34632a22a9d829ea1058381edfb24b2e7acf03106c5a2ad171f4ec174089fc3d270c3a70eee69a898aaee54faf6830b09eed5bc40c22d0
6
+ metadata.gz: b00d78c5c59e542dec762108d82b665bacf262a813e747761a6e2c9618e49f43fecd667c354190e9bf00df26e9acc8aa4115ff527615fc405382054aa631c7a2
7
+ data.tar.gz: 44bbf9d40c80f076e3c7a08b6a24f1d1ee4288cce5bc477d7020af0f22b2d968b7f6143f68541a3a95acfc46432296342bdbbef3cf7dcff052beca998dd84d47
@@ -0,0 +1,37 @@
1
+ require "rips/instructions"
2
+
3
+ module Rips
4
+ class Assembler
5
+
6
+ # @input: array with assembly instructions
7
+ # @output: array with coded instructions
8
+ # @cmd: line split on tokens (name + arguments)
9
+ # @instruction: instruction instance
10
+ # @line: number of file's line
11
+ def initialize
12
+ @input = []
13
+ @output = []
14
+ @cmd
15
+ @instruction
16
+ @line = 1
17
+ end
18
+
19
+ # Stores each new line of file
20
+ def << (value)
21
+ @input << value.strip
22
+ end
23
+
24
+ # Analyze and translate each instruction
25
+ def run
26
+ end
27
+
28
+ # Codification log of instruction
29
+ def show
30
+ end
31
+
32
+ # Generate output in "progfile.dat"
33
+ def generate
34
+ end
35
+
36
+ end
37
+ end
data/lib/rips/error.rb ADDED
@@ -0,0 +1,15 @@
1
+ module Rips
2
+ module Error
3
+
4
+ MESSAGES =
5
+ [ "RIPS ERROR (0). Unknown problem.",
6
+ "RIPS ERROR (1). No input file (try `rips file.rips`).",
7
+ "RIPS ERROR (2). Doesn't exist file or directory.",
8
+ "RIPS ERROR (3). Permission denied to read file." ]
9
+
10
+ def self.message (num, *args)
11
+ puts MESSAGES[num] % args
12
+ exit
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Rips
2
+ module Formats
3
+
4
+ class Format
5
+
6
+ attr_reader :opcode, :args_number
7
+
8
+ # @opcode = operation code in binary
9
+ # @args_number = number of format's arguments
10
+ def initialize (opcode, args_number)
11
+ @opcode, @args_number = opcode, args_number
12
+ end
13
+ end
14
+ end
15
+ end
File without changes
@@ -0,0 +1,17 @@
1
+ require "rips/instructions/set"
2
+ require "rips/formats"
3
+ require "rips/variables"
4
+
5
+ module Rips
6
+ module Instructions
7
+
8
+ class Instruction
9
+
10
+ # @name: mnemonic name
11
+ # @type: instruction format
12
+ def initialize (name, type)
13
+ @name,@type = name,type
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ module Rips
2
+ module Instructions
3
+
4
+ SET = []
5
+ end
6
+ end
File without changes
@@ -0,0 +1,14 @@
1
+ module Rips
2
+ module Variables
3
+
4
+ class Variable
5
+
6
+ attr_reader :length
7
+
8
+ # @length = max length of bits
9
+ def initialize (length)
10
+ @length = length
11
+ end
12
+ end
13
+ end
14
+ end
File without changes
data/lib/rips/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rips
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/rips.rb CHANGED
@@ -1,5 +1,25 @@
1
1
  require "rips/version"
2
+ require "rips/assembler"
3
+ require "rips/error"
2
4
 
3
5
  module Rips
4
- # Your code goes here...
6
+
7
+ # Check for a valid file
8
+ if ARGV.empty?
9
+ Error::message(1)
10
+ elsif !File.exist? ARGV[0]
11
+ Error::message(2)
12
+ elsif !File.readable? ARGV[0]
13
+ Error::message(3)
14
+ end
15
+
16
+ rips = Assembler.new
17
+
18
+ File.open(ARGV[0], "r") do |f|
19
+ f.each_line do |line|
20
+ rips << line
21
+ end
22
+ end
23
+
24
+ rips.run
5
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rips
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Madh93
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-04 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,6 +68,15 @@ files:
68
68
  - Rakefile
69
69
  - bin/rips
70
70
  - lib/rips.rb
71
+ - lib/rips/assembler.rb
72
+ - lib/rips/error.rb
73
+ - lib/rips/formats.rb
74
+ - lib/rips/formats/format.rb
75
+ - lib/rips/instructions.rb
76
+ - lib/rips/instructions/instruction.rb
77
+ - lib/rips/instructions/set.rb
78
+ - lib/rips/variables.rb
79
+ - lib/rips/variables/variable.rb
71
80
  - lib/rips/version.rb
72
81
  - rips.gemspec
73
82
  - spec/rips_spec.rb