changed the keyword in unit tests, prism and in the md

This commit is contained in:
Ekin 2021-06-16 11:14:35 +03:00
parent 8c51133cf1
commit 22669bc226
5 changed files with 21 additions and 21 deletions

View File

@ -30,7 +30,7 @@ func(x) return x*x end # Lambda/literal functions.
# If condition.
if x == 'foo'
print('bar')
elif x == 'bar'
elsif x == 'bar'
print('baz')
end

View File

@ -13,6 +13,6 @@ Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookb
// The below line was changed to the line below it.
// keyword:/\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/});
keyword:/\b(?:and|break|def|do|else|elif|end|for|if|in|module|not|or|raise|return|self|then|throw|while|yield|null|from|import|as|func|native|continue)\b/});
keyword:/\b(?:and|break|def|do|else|elsif|end|for|if|in|module|not|or|raise|return|self|then|throw|while|yield|null|from|import|as|func|native|continue)\b/});
var n={pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"tag"},rest:e.languages.ruby}};delete e.languages.ruby.function,e.languages.insertBefore("ruby","keyword",{regex:[{pattern:RegExp("%r(?:"+["([^a-zA-Z0-9\\s{(\\[<])(?:(?!\\1)[^\\\\]|\\\\[^])*\\1","\\((?:[^()\\\\]|\\\\[^])*\\)","\\{(?:[^#{}\\\\]|#(?:\\{[^}]+\\})?|\\\\[^])*\\}","\\[(?:[^\\[\\]\\\\]|\\\\[^])*\\]","<(?:[^<>\\\\]|\\\\[^])*>"].join("|")+")[egimnosux]{0,6}"),greedy:!0,inside:{interpolation:n}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:n}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:{pattern:/(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,lookbehind:!0},"method-definition":{pattern:/(\bdef\s+)[\w.]+/,lookbehind:!0,inside:{function:/\w+$/,rest:e.languages.ruby}}}),e.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,constant:/\b[A-Z]\w*(?:[?!]|\b)/}),e.languages.ruby.string=[{pattern:RegExp("%[qQiIwWxs]?(?:"+["([^a-zA-Z0-9\\s{(\\[<])(?:(?!\\1)[^\\\\]|\\\\[^])*\\1","\\((?:[^()\\\\]|\\\\[^])*\\)","\\{(?:[^#{}\\\\]|#(?:\\{[^}]+\\})?|\\\\[^])*\\}","\\[(?:[^\\[\\]\\\\]|\\\\[^])*\\]","<(?:[^<>\\\\]|\\\\[^])*>"].join("|")+")"),greedy:!0,inside:{interpolation:n}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:n}}],e.languages.rb=e.languages.ruby}(Prism);

View File

@ -49,52 +49,52 @@ def execute(expr)
if ptr >= mem.length then list_append(mem, 0) end
## Decrement the data pointer (to point to the next cell to the left).
elif c == '<'
elsif c == '<'
ptr -= 1
if ptr < 0 then assert(false, "ip < 0") end
## Increment (increase by one) the byte at the data pointer.
elif c == '+'
elsif c == '+'
if mem[ptr] == 255 then mem[ptr] = 0
else mem[ptr] += 1 end
## Decrement (decrease by one) the byte at the data pointer.
elif c == '-'
elsif c == '-'
if mem[ptr] == 0 then mem[ptr] = 255
else mem[ptr] -= 1 end
## output the byte at the data pointer.
elif c == '.'
elsif c == '.'
write(str_chr(mem[ptr]))
elif c == ','
elsif c == ','
assert(false, "Currently input isn't supported in pocketlang.")
## if the byte at the data pointer is zero, then instead of moving the
## instruction pointer forward to the next command, jump it forward to
## the command after the matching ] command.
elif c == '[' and mem[ptr] == 0
elsif c == '[' and mem[ptr] == 0
open = 0
while true
i += 1
if expr[i] == ']' and open == 0 then break end
if expr[i] == '[' then open += 1
elif expr[i] == ']' then open -= 1
elsif expr[i] == ']' then open -= 1
end assert(open >= 0)
end
## if the byte at the data pointer is nonzero, then instead of moving the
## instruction pointer forward to the next command, jump it back to the
## command after the matching [ command
elif c == ']' and mem[ptr] != 0
elsif c == ']' and mem[ptr] != 0
open = 0
while true
i -= 1
if expr[i] == '[' and open == 0 then break end
if expr[i] == ']' then open -= 1
elif expr[i] == '[' then open += 1
elsif expr[i] == '[' then open += 1
end assert(open <= 0)
end

View File

@ -2,8 +2,8 @@
for i in 1..100
if i%3 == 0 and i%5 == 0 then print('fizzbuzz')
elif i%3 == 0 then print('fizz')
elif i%5 == 0 then print('buzz')
elsif i%3 == 0 then print('fizz')
elsif i%5 == 0 then print('buzz')
else print(i)
end
end

View File

@ -7,21 +7,21 @@ if true then variable = 42 else unreachable() end
assert(variable == 42, 'If statement failed.')
if false then unreachable()
elif true then variable = null
elsif true then variable = null
else unreachable() end
assert(is_null(variable), 'Elif statement failed.')
assert(is_null(variable), 'elsif statement failed.')
if false then unreachable()
elif false then unreachable()
elif false then unreachable()
elsif false then unreachable()
elsif false then unreachable()
else variable = "changed" end
assert(variable == "changed", 'Else statement failed.')
if false then unreachable()
elif true
elsif true
if false
unreachable()
elif true
elsif true
variable = 123
else
unreachable()
@ -39,9 +39,9 @@ assert(variable == 1212)
while true
variable = 22
if true then elif false then end
if true then elsif false then end
if false
elif true
elsif true
variable += 2300
end
variable += 1