lscript 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lscript.rb +60 -35
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 257b087618522e6af59e4307b05b16d35f660884
|
4
|
+
data.tar.gz: ccc53082f5821ca0645278e56c7f14bdab306156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2279ceb693871d0815e768b28e35d1e979f6744b2297059cf393dc69447fbba7e2b151233437691548595496255be852a0db86fc99133c44c9b90559a997af7d
|
7
|
+
data.tar.gz: f1eaaa3605af44bebe67161af7d7f05482364c530ce09ece12c3cf6c5ea00cb9cd1d1edfd526b0f48a1fbafdb72da477713c8f11dad94ac27e2e42b6ec822651
|
data/lib/lscript.rb
CHANGED
@@ -1,35 +1,41 @@
|
|
1
1
|
def lscript(string)
|
2
|
-
|
2
|
+
variables = Hash.new
|
3
3
|
while true
|
4
4
|
case string.slice!(0)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
5
|
+
when 'g'
|
6
|
+
variables[string.slice!(0)] = gets.chomp
|
7
|
+
when 'p'
|
8
|
+
puts lread(string,variables)
|
9
|
+
when 'r'
|
10
|
+
variables[string.slice!(0)] = lread(string,variables)
|
11
|
+
when 'i'
|
12
|
+
#if true the code after runs, if false it gets eaten
|
13
|
+
if !(variables[string.slice!(0)] == variables[string.slice!(0)])
|
14
|
+
lread(string,variables)
|
15
|
+
end
|
16
|
+
when 'e'
|
17
|
+
return variables[string.slice!(0)]
|
18
|
+
when '+'
|
19
|
+
variables[string.slice!(0)] = variables[string.slice!(0)] + variables[string.slice!(0)]
|
20
|
+
when '-'
|
21
|
+
variables[string.slice!(0)] = variables[string.slice!(0)] - variables[string.slice!(0)]
|
22
|
+
when nil
|
23
|
+
return variables
|
24
|
+
else
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
27
|
-
def lread(string)
|
28
|
-
|
29
|
-
|
30
|
-
ret
|
28
|
+
def lread(string,variables)
|
29
|
+
x = string.slice!(0)
|
30
|
+
if x == '{'
|
31
|
+
ret = ""
|
32
|
+
until (s=string.slice!(0)) == '}'
|
33
|
+
ret += s
|
34
|
+
end
|
35
|
+
return ret
|
36
|
+
else
|
37
|
+
return variables[x]
|
31
38
|
end
|
32
|
-
return ret
|
33
39
|
end
|
34
40
|
|
35
41
|
=begin
|
@@ -40,19 +46,38 @@ $ = single character variabel, a-z are recommended. 0-9 aswell as other characte
|
|
40
46
|
_ text or code to read or run
|
41
47
|
; defines end of text or code to read
|
42
48
|
g$ gets user input and stores in variabel $
|
43
|
-
p$ puts $
|
44
|
-
|
45
|
-
|
49
|
+
p$ puts $ to console
|
50
|
+
p{_} puts _ string to console
|
51
|
+
r${_} puts _ string into $
|
52
|
+
i$${_} if $ == $ runs _
|
46
53
|
+$$$ combines second and third varaible into first
|
47
54
|
-$$$ subtracts second and third varaible into first, works best with numbers
|
55
|
+
e$ stops the code and returns the variable
|
48
56
|
|
49
57
|
Lets run trough an example
|
50
|
-
lscript("
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
58
|
+
lscript("p{What is your name?} ra{Hello } gb +cab pc")
|
59
|
+
p{What is your name?} this will puts to console[p] the string[What is your name?] and stop reading at [}]
|
60
|
+
ra{Hello } this will read[r] into variable[a] the string[Hello ] and stop at [}] (notice the space after Hello, it is important for formating later)
|
61
|
+
gb this will gets[g] user input into the varaibel[b]
|
62
|
+
+cab this will add[+] into varable[c] the other 2 variabels [a] and [b]
|
63
|
+
pc finally this will puts[p] the combined variable[c] to console
|
64
|
+
|
65
|
+
CHANGELOG
|
66
|
+
0.0.1
|
67
|
+
Initial release
|
68
|
+
|
69
|
+
0.0.2
|
70
|
+
When the code is finished return the variables hash incase the user needs it
|
71
|
+
Added command e$, allows user to exit the code and return a specific variable
|
72
|
+
Extended text read fucntionallity
|
73
|
+
p command can now read text directly
|
74
|
+
strings are noted as {_} now instead of _; for both clarity and for the extended fucntions
|
75
|
+
updated example code to reflect changes
|
76
|
+
g command now uses .chomp to remove new line character
|
77
|
+
|
78
|
+
Planed additions:
|
79
|
+
Possibly remodell into an object, allowing for continuing the same run with multiple run calls
|
80
|
+
Make - command acutally work, and try to convert string into numbers
|
81
|
+
Make both + and - use new string reading system, so you wont have to save text to a varibale before useing
|
57
82
|
=end
|
58
83
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leddy231
|
@@ -10,7 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: A simple scripting language that reads a single string and executes commands.
|
14
|
+
Variables, ifs and +/- operations supported. Very basic as it is, will be expanded
|
15
|
+
more. Read the lscript.rb for changelog and instructions
|
14
16
|
email:
|
15
17
|
executables: []
|
16
18
|
extensions: []
|