म
MarathiCodeby Sprout Tech
Documentation topicsProgram Execution
MarathiCode v0.2.0

Program Execution

प्रोग्राम कसा चालतो

Running a MarathiCode program happens in four steps:

  1. Lexing: the source text is split into tokens (keywords, names, numbers, strings, symbols).
  2. Parsing: the whole program is checked against the grammar and turned into a syntax tree.
  3. Interpreting: statements run one at a time, from top to bottom.
  4. Output: each छापा prints one line.

Syntax errors stop everything

Because the whole program is parsed before it runs, a syntax error anywhere means nothing is printed, not even the lines before it:

syntax_first.mr
छापा("पहिली ओळ")
चल x = (1 + 2
Output / Error (आउटपुट / त्रुटी)
वाक्यरचना त्रुटी (Syntax Error)
अपूर्ण वाक्य (Unexpected end of input)

Runtime errors keep earlier output

A runtime error stops the program, but whatever was already printed stays:

runtime_stop.mr
छापा("आधी")
छापा(10 / 0)
छापा("नंतर")
Output / Error (आउटपुट / त्रुटी)
आधी
धावपळ त्रुटी (Runtime Error)
ओळ 2:
    छापा(10 / 0)
शून्याने भागाकार करता येत नाही (Division by zero).

Define functions before calling them

A function exists once its कार्य statement has run. Calling it on an earlier line is an error:

order.mr
नमस्कार()

कार्य नमस्कार() {
    छापा("नमस्कार")
}
Output / Error (आउटपुट / त्रुटी)
धावपळ त्रुटी (Runtime Error)
ओळ 1:
    नमस्कार()
कार्य 'नमस्कार' सापडले नाही.

Limits

  • Function calls can be nested up to 1,000 deep (for example, recursion). Going deeper is a runtime error.
  • In the Playground only, a run stops after 1,000,000 loop iterations in total.