{"id":17475258,"url":"https://github.com/treeplate/postfix_script_interpreter","last_synced_at":"2025-03-28T11:25:15.342Z","repository":{"id":134392353,"uuid":"304415019","full_name":"treeplate/postfix_script_interpreter","owner":"treeplate","description":null,"archived":false,"fork":false,"pushed_at":"2021-11-24T19:36:32.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T11:44:33.635Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/treeplate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-15T18:28:19.000Z","updated_at":"2021-11-24T19:36:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd66b24b-1dff-420d-912f-bdcb4caecdbe","html_url":"https://github.com/treeplate/postfix_script_interpreter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeplate%2Fpostfix_script_interpreter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeplate%2Fpostfix_script_interpreter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeplate%2Fpostfix_script_interpreter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeplate%2Fpostfix_script_interpreter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treeplate","download_url":"https://codeload.github.com/treeplate/postfix_script_interpreter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246019248,"owners_count":20710540,"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":[],"created_at":"2024-10-18T18:43:44.913Z","updated_at":"2025-03-28T11:25:15.320Z","avatar_url":"https://github.com/treeplate.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostFix Script\nA language whose main feature is postfix functions.\n\n# Bug reporting\n\nReport an error/feature request at [the New Issue Github page](https://github.com/treeplate/postfix_script_interpreter/issues/new)\n\nView what is happening with your issues in [my language flow](https://github.com/treeplate/postfix_script_interpreter/projects/1)\n\n# Introduction\n\nPostFixScript is a dynamically typed language with structured record types.\n\nSource files come in pairs. The first is a \".inc\" file that lists the files to import before compiling the second file, which is a \".pfs\" file. Paths in the \".inc\" files are relative to the current working directory.\n\nThere is one global scope shared by all files.\n\n## Language reference\n\nA PFS file is a statement block.\n\n### Comments\n\nComments start with two slashes (`//`) not in a string literal, and end at next line feed.\n\nComments are treated like whitespace.\n\n### Scopes\n\nIdentifiers (e.g for variables and functions) share a single namespace.\n\nBlocks, functions, and instances each introduce a new scope. Scopes are lexically nested.\n\n### Types\n\nValues can be null, true, false, doubles, strings, functions, or instances of classes.\n\n### Statements\n\n#### Statement blocks `(\u003cblock\u003e)`\n\nA statement block is a list of statements. There are several kinds of statements, each listed in this section.\n\nSome statements can be followed by a comma to indicate the end of the statement. These commas are always optional, though they may be necessary to separate two statements that would otherwise be interpreted as a single longer statement.\n\n#### Print\n\n```\nprint \u003cexpr\u003e;\n```\n\nPrints the result of evaluating \u003cexpr\u003e to the console.\n\n#### If\n\n```\nif \u003cexpr\u003e { \u003cblock\u003e }\nif \u003cexpr\u003e { \u003cblock\u003e } else { \u003cblock\u003e }\n```\n\nEvaluates the expression. If the result is true, runs the first block, otherwise runs the second (if present). It is an error for the expression to not return true or false.\n\n#### Assignment\n\n```\nvar \u003cidentifier\u003e = \u003cexpr\u003e;\n```\n\nAssigns the result of evaluating the given expression to the variable with the given identifier.\n\nIf there is variable with the given identifier in scope, that is the variable referenced by the assignment statement. Otherwise, a new variable is introduced in the nearest enclosing scope.\n\nThis has some surprising side-effects; for example, consider the following two examples:\n\n```\nvar foo = 0\nfun test() {\n  var foo = 1\n}\ntest()\nprint foo // prints 1\n```\n\n```\nfun test() {\n  var foo = 1\n}\nvar foo = 0\ntest()\nprint foo // prints 0\n```\n\n#### Return\n\n```\nreturn \u003cexpr\u003e;\n```\n\nCauses the nearest enclosing function execution to be interrupted, returning the value of the given expression.\n\nIt is an error to call a return statement outside a function.\n\n#### Function declarations\n\n```\nfun \u003cidentifier\u003e(\u003cparameters\u003e) { \u003cblock\u003e }\n```\n\nIntroduces a new variable to the nearest enclosing scope whose name is the given identifier and whose value is a function. Parameters are a comma separated-list of identifiers.\n\nThere is a function called `type` that tells you the type of its argument:\n\n* `\"boolean\"`\n* `\"number\"`\n* `\"string\"`\n* `\"function\"`\n* `\"class\"`\n* `\u003cinstance type\u003e`\n\nSee the section on function invocations below for details on how parameters are bound.\n\n\n#### Classes\n\n```\nclass \u003cidentifier\u003e {\n  \u003cvariable assignments\u003e\n  \u003cfunction declarations\u003e\n}\n```\n\nIntroduces a new variable to the nearest enclosing scope whose name is the given identifier and whose value is a function with no parameters that returns a new instance of the class.\n\nWhen a new instance is created, the variable assignments and function declarations of the class are evaluated in the context of a new scope (the instance scope), and then, if there is a variable called `init` in scope of the instance, it is called as a function with no arguments (see below).\n\n##### Operator Overloads\n\nThere are many operator overloads, described here:\n* `plus`: Takes one argument; corresponds to `+`.\n* `minus`: Takes one argument; corresponds to `-`.\n* `negate`: Takes no arguments; corresponds to unary `-`.\n* `times`: Takes one argument; corresponds to `*`.\n* `div`: Takes one argument; corresponds to `/`.\n* `equals`: Takes one argument; corresponds to `=`.\n* `toStr`: Takes no argument; must return string; corresponds to `$`.\n\n#### Expression statements\n\n```\n\u003cexpr\u003e,\n```\n\nEvaluates the expression and discards the result.\n\n\n### Expressions\n\nThere are various forms of expressions. They are processed in the order listed in this section.\n\n* `\u003cexpr\u003e or \u003cexpr\u003e`: Left hand side must evaluate to a boolean value. If it is true, returns true, otherwise, returns the right hand side, which must evaluate to a boolean value.\n* `\u003cexpr\u003e != \u003cexpr\u003e`: Evaluates both expressions, returns true if they are not equal, otherwise returns false.\n* `\u003cexpr\u003e = \u003cexpr\u003e`: Evaluates both expressions, returns true if they are equal, otherwise returns false.\n* `\u003cexpr\u003e \u003c \u003cexpr\u003e`: Evaluates both expressions, which must both be numbers. Returns true if the left hand side is smaller than the right hand side, otherwise returns false.\n* `\u003cexpr\u003e + \u003cexpr\u003e`: Evaluates both expressions, which must both be numbers or both be strings. Returns the sum if they are both numbers or the concatenation if they are both strings.\n* `\u003cexpr\u003e - \u003cexpr\u003e`: Evaluates both expressions, which must both be numbers. Returns the result of substracting the right hand side from the left hand side.\n* `\u003cexpr\u003e * \u003cexpr\u003e`: Evaluates both expressions, which must both be numbers. Returns their product.\n* `\u003cexpr\u003e / \u003cexpr\u003e`: Evaluates both expressions, which must both be numbers. Returns the result of dividing the left hand side by the right hand side.\n* Postfix function invocation (see below).\n* C-style function invocation (see below).\n* `$\u003cexpr\u003e`: Evaluates the expression and returns its string value.\n* `-\u003cexpr\u003e`: Evaluates the expression and returns its negation.\n* `(\u003cexpr\u003e)`: Evaluates and returns the nested expression.\n* `\u003cexpr\u003e . \u003cexpr\u003e`: The first expression must be an instance of a class. Evaluates the second one with the scope of the first.\n* `\u003cidentifier\u003e`: Returns the value of the variable with that name in the nearest enclosing scope that has a variable of that name.\n* Literals (see below).\n\n#### Function invocations\n\n##### Postfix syntax\n\n```\n\u003cexpr\u003e \u003cidentifier\u003e\n```\n\nIf a function has a single argument, it can be called by postfix notation, giving the argument as an expression before the identifier. If the identifier specifies a variable in scope, then it is called with the value of the given expression as the first argument.\n\n##### C-style syntax\n\nFunctions can also be called by specifying the identifier that specifies a variable in scope whose value is a function followed by a comma-separated list of expressions inside parentheses. Each expression is evaluated in left-to-right order, and the values of those expressions is passed to the function as the function's arguments.\n\n##### Function invocation semantics\n\nWhen a function is called, a new scope is created. The given arguments are mapped to the function's declared parameters. The number of arguments differing is an error.\n\n#### Literals\n\n* `1`, `1.0`: (positive) (numbers with fractional component)\n* \"string\": a string\n* `true`, `false`: booleans\n* `nil`: null\n* `newline`: newline\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreeplate%2Fpostfix_script_interpreter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreeplate%2Fpostfix_script_interpreter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreeplate%2Fpostfix_script_interpreter/lists"}