From f150feeb705930bcfb2d6f5c9c726637f81accec Mon Sep 17 00:00:00 2001 From: CapitalEx Date: Thu, 22 Dec 2022 18:54:35 -0500 Subject: [PATCH] Add Factor Support --- LANGUAGES.md | 1 + examples/language/factor.factor | 23 ++++++ languages.json | 132 ++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 examples/language/factor.factor diff --git a/LANGUAGES.md b/LANGUAGES.md index 5a3b9842..552515a1 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -75,6 +75,7 @@ Expect (exp) Extensible Stylesheet Language Transformations (xslt,xsl) F# (fs,fsi,fsx,fsscript) F* (fst) +Factor (factor) Fennel (fnl) FIDL (fidl) Fish (fish) diff --git a/examples/language/factor.factor b/examples/language/factor.factor new file mode 100644 index 00000000..a90a648a --- /dev/null +++ b/examples/language/factor.factor @@ -0,0 +1,23 @@ +! Written for SCC by CapitalEx +USING: combinators io kernel math.order math.parser random +ranges ; +IN: simple-guessing-game + +: pick-number ( -- n ) + 100 [1..b] random ; + +: read-number ( -- n ) + "Enter a guess: " write readln dec> ; + +: guessing-game ( n -- ) + dup read-number <=> dup { + { +lt+ [ "Too high!" print t ] } + { +gt+ [ "Too low!" print t ] } + [ drop "You won!" print f ] + } case [ guessing-game ] [ drop ] if ; + +MAIN: [ + "I'm thinking of a number between 1 and 100" print + pick-number + guessing-game +] \ No newline at end of file diff --git a/languages.json b/languages.json index 2145e79d..ab07a4ae 100644 --- a/languages.json +++ b/languages.json @@ -2119,6 +2119,138 @@ ], "quotes": [] }, + "Factor" :{ + "complexitychecks": [ + "if", + "when", + "unless", + "if*", + "when*", + "unless*", + "?if", + "?", + "cond", + "case", + + "cond>quot", + "case>quot", + "alist>quot", + + "while", + "until", + "loop", + + "0&&", + "1&&", + "2&&", + "3&&", + "n&&", + "&&", + + "0||", + "1||", + "2||", + "3||", + "n||", + "||", + + "and", + "or", + "xor", + + "eq", + "=", + + "smart-if", + "smart-if*", + "smart-when", + "smart-when*", + "smart-unless", + "smart-unless*" + ], + "extensions": [ + "factor" + ], + "multi_line": [ + [ + "![[", + "]]" + ], + [ + "![=[", + "]=]" + ], + [ + "![==[", + "]==]" + ], + [ + "![===[", + "]===]" + ], + [ + "![====[", + "]====]" + ], + [ + "![=====[", + "]=====]" + ], + [ + "![======[", + "]======]" + ], + [ + "/*", + "*/" + ], + [ + "((", + "))" + ] + ], + "line_comment": [ + "!" + ], + "quotes": [ + { + "start": "\"", + "end": "\"" + }, + { + "start": "STRING:", + "end": ";" + }, + { + "start": "[======[", + "end": "]======]" + }, + { + "start": "[=====[", + "end": "]====]" + }, + { + "start": "[====[", + "end": "]====]" + }, + { + "start": "[===[", + "end": "]===]" + }, + { + "start": "[==[", + "end": "]==]" + }, + { + "start": "[=[", + "end": "]=]" + }, + { + "start": "[[", + "end": "]]" + } + ] + }, "Fennel": { "complexitychecks": [ "(for",