{"id":24468980,"url":"https://github.com/flybywiresim/rnp","last_synced_at":"2025-04-13T10:23:44.585Z","repository":{"id":102998684,"uuid":"316051931","full_name":"flybywiresim/rnp","owner":"flybywiresim","description":"RNP is a language which compiles to RPN, a scripting language used by MSFS.","archived":false,"fork":false,"pushed_at":"2021-05-22T17:34:25.000Z","size":238,"stargazers_count":12,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T04:28:49.114Z","etag":null,"topics":["compiler","flight-simulator","scripting-language"],"latest_commit_sha":null,"homepage":"https://flybywiresim.github.io/rnp","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flybywiresim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-11-25T20:56:16.000Z","updated_at":"2025-01-12T23:26:01.000Z","dependencies_parsed_at":"2023-04-10T19:55:42.242Z","dependency_job_id":null,"html_url":"https://github.com/flybywiresim/rnp","commit_stats":{"total_commits":55,"total_committers":1,"mean_commits":55.0,"dds":0.0,"last_synced_commit":"d09bcc8536ba2aa03a9787017f3bc799cbbd25a3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flybywiresim%2Frnp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flybywiresim%2Frnp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flybywiresim%2Frnp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flybywiresim%2Frnp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flybywiresim","download_url":"https://codeload.github.com/flybywiresim/rnp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581085,"owners_count":21128099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","flight-simulator","scripting-language"],"created_at":"2025-01-21T07:13:41.064Z","updated_at":"2025-04-13T10:23:44.555Z","avatar_url":"https://github.com/flybywiresim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RNP\n\nRNP is a language which compiles to [RPN][], a scripting language used by MSFS.\n\nRNP provides a familiar and expressive environment with strict types. In\nthe future it may also perform optimization.\n\n## API\n\n```js\nconst { Type, translate } = require('@flybywiresim/rnp');\n\n// function to resolve imports\nfunction getSource(\n  referrer,  // specifier of importing module\n  specifier, // specifier of module to be imported\n) {\n  // return `null` if module can't be resolved.\n  return {\n    source,    // source of imported module\n    specifier, // resolved specifier, e.g. `dirname(referrer).join(specifier)`\n  };\n}\n\nconst {\n  output,    // string RPN output\n  messages,  // [{ level, message, location }]\n} = translate(source, {\n  specifier,   // defaults to '(anonymous)'\n  returnType,  // defaults to `Type.VOID`\n  getSource,   // defaults to resolution error\n});\n```\n\n## Types\n\n- `boolean` - `true` or `false`.\n- `number` - IEEE-754 double precision floating point number.\n- `string` - A string type.\n- `any` - Used for unknown types. No builtin in the language allows this type,\n   but some expressions may be valid with it, for example `(L:X) = (L:Y)`.\n- `void` - The absence of a value. An example of an expression which produces\n  `void` is `if true {}`.\n\n## Syntax\n\n### Comments\n\n#### Line Comments\n\nComment out a single line.\n\n```rnp\n// this is a line comment\n```\n\n#### Block Comments\n\nComment out multiple lines. Nesting is allowed.\n\n```rnp\n/* this\ncomment\nis\nlonger\n*/\n```\n\n```rnp\n/*\n\n/*\ncomment doesn't end here\n*/\n\ncomment ends here\n*/\n```\n\n### Declarations\n\n#### Locals\n\nDeclare a local.\n\n```rnp\nlet a = 1;\n```\n\n### Aliases\n\nSimVars can be aliased to local names.\n\n```rnp\nalias x = (L:X, bool);\n\nx = true; // set L:X to true\nif x {    // if L:X is true\n}\n```\n\n#### Macros\n\nDeclare a macro. Macros may be exported using `export`. Macros are \"hygienic\",\nmeaning that identifiers may not be implicitly leaked into or out of a macro\nscope. Macros parameters use `$` to avoid being confused with normal variables.\n\n```rnp\nmacro add($a, $b) {\n  $a + $b\n}\n```\n\n```rnp\nexport macro sub($a, $b) {\n  $a - $b\n}\n```\n\n```rnp\nmacro assign($a) {\n  $a = 1;\n}\n\nlet b = 0;\n// does not break hygiene rules because `b` was explicitly passed\nassign(b);\n```\n\n#### Imports\n\nMacros can be imported from other files using `import`.\n\n```rnp\nimport { sub } from './file.rnp';\n```\n\n### Assignments\n\n#### Locals\n\nAssign a value to a local.\n\n```rnp\na = 1;\n```\n\n#### SimVars\n\nAssign a value to a SimVar.\n\n```rnp\n(X:Y) = 1;\n(X:Y, unit) = 1;\n```\n\n### Expressions\n\n#### Literals\n\n```rnp\n// booleans\ntrue;\nfalse;\n\n// numbers\n1.0;\n0x10;\n0b101010;\n\n// strings\n'hello';\n```\n\n#### Locals\n\nReference a local.\n\n```rnp\na\n```\n\n#### SimVars\n\nReference a SimVar.\n\n```rnp\n(X:Y)\n(X:Y, unit)\n```\n\n#### Templates\n\nAllows XML substitutions. Expressions must be typed.\n\n```rnp\nlet x = #X, bool#;\n```\n\n```rnp\n#Y#;\n```\n\n#### Macro Expansion\n\nExpand a macro.\n\n```rnp\nadd(1, 2);\n```\n\n#### Blocks\n\n```rnp\n{\n  1\n}\n```\n\n#### If Expressions\n\nConditional evaluation, may be used as an expression.\n\n```rnp\nif x {\n}\n```\n\n```rnp\nif x {\n} else {\n}\n```\n\n```rnp\nif x {\n} else if y {\n} else {\n}\n```\n\n```rnp\nlet a = if x { 1 } else { 2 };\n```\n\n#### Binary and Unary Operators\n\nMathematical and relational operations.\n\n```rnp\n1 + 1;\n1 / 1;\n'hello' == 'hello';\n// etc...\n\n!true\n~1\n// etc...\n```\n\n#### Method Operations\n\nRPN provides several standard operations. These operations are available in\nRNP as method-ish syntax.\n\n```rnp\n8.log(2);\n```\n\n```rnp\n'hello'.toUpperCase();\n```\n\n[RPN]: https://www.prepar3d.com/SDKv5/sdk/scripting/rpn_scripting.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflybywiresim%2Frnp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflybywiresim%2Frnp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflybywiresim%2Frnp/lists"}