ASPL لباتASPL 0.7.0

Search documentation

Search starts with current English documentation · ASPL 0.7.0

Enter a complete name such as read_line, or words about a topic.

    العربية
    Source files

    Open one UTF-8 .aspl or .لبات file, up to 1 MiB, in a new draft. It stays in this browser and does not run automatically.

    First output and reading diagnostics

    ASPL 0.7.0 · Current release

    Change a greeting, predict its newline, separate output from status, and repair a missing brace.

    On this page

    What you will learn

    You will change a greeting, predict its exact output, and use a reported source location to repair an error. You will also tell printed text apart from the program's status.

    Before you begin

    No programming experience or installation is required. First program in the browser explains the playground controls. Source is the text of your program. Checking asks whether that source obeys the language rules. Run checks it and, if checking succeeds, executes its instructions.

    Opening any complete example below creates a new Home draft with its original source. Your earlier drafts and edits remain available. Opening checks the source but does not run it. Choose Run yourself. Documentation language and source vocabulary are separate. The example selector offers supplied Arabic and English keywords; it does not translate the greeting inside quotes or your draft.

    Read a complete program

    ASPL needs a reserved entry function, named ابدأ_الرئيسية or its exact English alias start_main. Execution starts there. fn / دالة introduces a function. The empty () means this entry takes no arguments. -> i64 / -> ص64 means it returns an integer status. Keep this entry signature as supplied while you learn the instructions inside it.

    The opening and closing braces mark the function's body. Instructions run in order inside that body. print / اطبع writes a string, which is text between double quotes. The parentheses pass that string to print. print adds no newline. The two source characters \n inside the string request one newline, so the next output starts on a new line. English statements end with ;, and Arabic statements may end with .. Neither terminator becomes output.

    return 0 / أرجع 0 ends the entry normally with process status 0. It does not print the digit zero. You will use this same ending in each independent lesson. Defining other functions comes later.

    Browser and native · ASPL 0.7.0 · English source

    Execution: Browser and native · ASPL 0.7.0

    Prerequisites:
    • Read the example explanation in its lesson before running.

    Input: No input lines are required.

    fn start_main() -> i64 {
        print("Hello\n");
        return 0;
    }
    
    Download lesson-first-output.aspl

    Expected outcomes
    {
      "browser": {
        "check": "success",
        "class": "success",
        "output": "Hello\n",
        "processStatus": 0
      },
      "native": {
        "check": 0,
        "status": 0,
        "output": "Hello\n"
      }
    }

    After Run, the Output area contains Hello followed by one newline, exactly Hello\n when written with an escape. The status area reports normal completion with start_main 0. The source contains quotes and a terminator; the output contains neither.

    Predict before running

    What exact text will appear, and does it end with a newline? Will 0 appear in Output? Make your prediction, then run the example and compare. You should find one line, Hello, with a trailing newline and no printed zero.

    Change the greeting

    Change only Hello to Welcome inside the quotes. Keep \n. Expected behavior is exactly Welcome\n, with normal status 0. Write your prediction before pressing Run.

    Change the greeting to Welcome and compare the exact line and newline.

    Hint: Edit the text between the quotes. Leave the newline escape, entry signature and return alone.

    Show worked answer

    Only the string changes. The call prints Welcome and one newline; return 0 still ends normally without printing zero. The complete solution below opens as another draft, so you can compare it with your own change.

    Browser and native · ASPL 0.7.0 · English source

    Execution: Browser and native · ASPL 0.7.0

    Prerequisites:
    • Read the example explanation in its lesson before running.

    Input: No input lines are required.

    fn start_main() -> i64 {
        print("Welcome\n");
        return 0;
    }
    
    Download lesson-first-output-solution.aspl

    Expected outcomes
    {
      "browser": {
        "check": "success",
        "class": "success",
        "output": "Welcome\n",
        "processStatus": 0
      },
      "native": {
        "check": 0,
        "status": 0,
        "output": "Welcome\n"
      }
    }

    Follow a source error to its location

    This is an intentionally broken complete-program variant. Its closing brace is missing. Open it to inspect the check result before trying to run it.

    Browser and native · ASPL 0.7.0 · English source

    Execution: Browser and native · ASPL 0.7.0

    Prerequisites:
    • Read the example explanation in its lesson before running.

    Input: No input lines are required.

    fn start_main() -> i64 {
        print("Hello\n");
        return 0;
    
    Download lesson-first-output-broken.aspl

    Expected outcomes
    {
      "browser": {
        "check": "source-error",
        "class": "source-error",
        "output": "",
        "reason": "expected-token"
      },
      "native": {
        "check": 1,
        "status": 1,
        "output": "",
        "reason": "expected-token"
      }
    }

    Checking reports a source error with reason expected-token: it expected right-brace and found end-of-file. The location is line 4, column 1, immediately after the last instruction. Select the reported location in the playground. The marker can sit at the end of the source because the missing character has no existing text to highlight.

    Insert the missing closing brace at that location. The labelled fragment below shows only the character to insert, not an independent program.

    Illustrative fragment

    }

    The corrected program is the original greeting example. Checking now succeeds; choose Run to get Hello\n and status 0. The broken source executes no instructions and produces no greeting, even though the print instruction appears before the missing brace. A source diagnostic describes rejected source. Output comes from executed instructions. A normal status describes how execution ended. Read more about diagnostics and outcomes.

    Check your understanding

    You are ready to continue when you can explain where execution starts, why the newline is explicit, why zero is not printed, and how you repaired the missing brace. These are self-checks. They save no grade or progress and never lock navigation. Continue to bindings and arithmetic whenever you choose.

    Browse pages