-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
125 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
slug: /hello-world | ||
--- | ||
|
||
# Hello World | ||
|
||
The simplest example of a program in Rue is the classic hello world example. | ||
|
||
Write the following program in a file named `hello.rue`: | ||
|
||
```rue title="hello.rue" | ||
fun main() -> Bytes { | ||
"Hello, world!" | ||
} | ||
``` | ||
|
||
Now, run the following command to run the file: | ||
|
||
```bash | ||
rue build hello.rue --run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import siteConfig from "@generated/docusaurus.config"; | ||
import type * as PrismNamespace from "prismjs"; | ||
import type { Optional } from "utility-types"; | ||
|
||
export default function prismIncludeLanguages( | ||
PrismObject: typeof PrismNamespace, | ||
): void { | ||
const { | ||
themeConfig: { prism }, | ||
} = siteConfig; | ||
const { additionalLanguages } = prism as { additionalLanguages: string[] }; | ||
|
||
globalThis.Prism = PrismObject; | ||
|
||
additionalLanguages.forEach((lang) => { | ||
if (lang === "php") { | ||
// eslint-disable-next-line global-require | ||
require("prismjs/components/prism-markup-templating.js"); | ||
} | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
require(`prismjs/components/prism-${lang}`); | ||
}); | ||
|
||
require("./prism-rue"); | ||
|
||
delete (globalThis as Optional<typeof globalThis, "Prism">).Prism; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Prism.languages.rue = { | ||
function: { | ||
pattern: /(\bfun\s+)[a-zA-Z_][a-zA-Z0-9_]*/, | ||
lookbehind: true, | ||
}, | ||
"function-call": { | ||
pattern: /\b[a-zA-Z_][a-zA-Z0-9_]*(?=\s*(?:\(|<.*?>\())/, | ||
alias: "function", | ||
}, | ||
field: { | ||
pattern: /\b[a-zA-Z_][a-zA-Z0-9_]*(?=\s*:)/, | ||
alias: "property", | ||
}, | ||
"field-access": { | ||
pattern: /\b(\.)([a-zA-Z_][a-zA-Z0-9_]*)/, | ||
lookbehind: true, | ||
alias: "property", | ||
}, | ||
string: { | ||
pattern: /"[^"]*"/, | ||
lookbehind: true, | ||
greedy: true, | ||
}, | ||
comment: { | ||
pattern: /\/\/.*|\/\*[^]*?\*\//, | ||
multiline: true, | ||
greedy: true, | ||
}, | ||
number: /\b[0-9][0-9_]*\b/, | ||
operator: /[+\-*?%!\^]|<[<=]?|>[>=]?|=[=>]?|!=?|\.(?:\.\.)?|::|->?|&&?|\|\|?/, | ||
punctuation: /[(){}[\],:]/, | ||
"control-flow": { | ||
pattern: /\b(?:if|else|return|raise|assert|assume)\b/, | ||
alias: "keyword", | ||
}, | ||
binding: { | ||
pattern: /\b(?:let|const|fun)\b/, | ||
alias: "keyword", | ||
}, | ||
type: { | ||
pattern: /\b(?:type|struct|enum|as|is)\b/, | ||
alias: "keyword", | ||
}, | ||
module: { | ||
pattern: /\b(?:import|mod)\b/, | ||
alias: "keyword", | ||
}, | ||
modifier: { pattern: /\b(?:inline|export)\b/, alias: "keyword" }, | ||
boolean: /\b(?:false|true)\b/, | ||
null: { | ||
pattern: /\bnil\b/, | ||
alias: "constant", | ||
}, | ||
builtin: /\b(?:Int|Any|Bytes32|Bytes|PublicKey|Nil|Bool)\b/, | ||
"class-name": /\b[A-Z][a-z][a-zA-Z0-9_]*\b/, | ||
}; |