From 22669bc226c218a4b08ff25540139699922553b5 Mon Sep 17 00:00:00 2001 From: Ekin Date: Wed, 16 Jun 2021 11:14:35 +0300 Subject: [PATCH] changed the keyword in unit tests, prism and in the md --- .../Getting-Started/learn-in-15-minutes.md | 2 +- docs/static/prism/prism.js | 2 +- tests/examples/brainfuck.pk | 18 +++++++++--------- tests/examples/fizzbuzz.pk | 4 ++-- tests/lang/controlflow.pk | 16 ++++++++-------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/pages/Getting-Started/learn-in-15-minutes.md b/docs/pages/Getting-Started/learn-in-15-minutes.md index caaf47c..08cbc1e 100644 --- a/docs/pages/Getting-Started/learn-in-15-minutes.md +++ b/docs/pages/Getting-Started/learn-in-15-minutes.md @@ -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 diff --git a/docs/static/prism/prism.js b/docs/static/prism/prism.js index cbedbec..63711b3 100644 --- a/docs/static/prism/prism.js +++ b/docs/static/prism/prism.js @@ -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); diff --git a/tests/examples/brainfuck.pk b/tests/examples/brainfuck.pk index 7560b64..193dc4e 100644 --- a/tests/examples/brainfuck.pk +++ b/tests/examples/brainfuck.pk @@ -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 diff --git a/tests/examples/fizzbuzz.pk b/tests/examples/fizzbuzz.pk index 56bfcc4..846dfbc 100644 --- a/tests/examples/fizzbuzz.pk +++ b/tests/examples/fizzbuzz.pk @@ -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 diff --git a/tests/lang/controlflow.pk b/tests/lang/controlflow.pk index e7e48f4..c1e36aa 100644 --- a/tests/lang/controlflow.pk +++ b/tests/lang/controlflow.pk @@ -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