WASDEV(The AI WorkShop)Docs Website Download

Chapter 1 · GAD language

Your first GAD program

Create a GAD file in WASDEV, run it, check it and format it. Every command on this page was run in the WASDEV terminal.

Write the program

  1. Open a project folder in WASDEV.
  2. In the explorer, create a file named bilten.gad.
  3. Type the program below. WASDEV colours the keywords and proposes them while you type.
  4. Press Ctrl+S to save.
# bilten.gad — kalkile mwayèn yon klas

fè mwayèn ak nòt-yo
    echèk "Pa gen okenn nòt pou kalkile." si nòt-yo vid
    retounen sonm(nòt-yo) / longè nòt-yo
fini

fè apresyasyon ak m
    retounen "Ekselan" si m pa mwens pase 90
    retounen "Trè byen" si m pa mwens pase 75
    retounen "Byen" si m pa mwens pase 60
    retounen "Dwe travay plis"
fini

elèv-yo = [
    { non: "Jira", nòt: [90, 85, 95] },
    { non: "Bosou", nòt: [60, 72, 68] },
    { non: "Ayida", nòt: [45, 55, 50] }
]

montre "BILTEN KLAS LA"
pou chak e nan elèv-yo
    m = mwayèn(e.nòt)
    montre "{e.non} : {won(m)} — {apresyasyon(m)}"
fini
montre "Kantite elèv : {longè elèv-yo}"
  • A line that starts with # is a comment.
  • A block closes with fini. Indentation is free.
  • Text between { and } inside a string is replaced by its value.

Run it

The program and its result in the WASDEV terminal
The program and its result in the WASDEV terminal
  1. Keep the file open in the editor.
  2. Press F5. WASDEV runs the file with the GAD compiler and shows the result in the terminal.
  3. Or type the command yourself in the terminal: gad kouri bilten.gad.
BILTEN KLAS LA
Jira : 90 — Ekselan
Bosou : 67 — Byen
Ayida : 50 — Dwe travay plis
Kantite elèv : 3

Check and format

  1. Open the Run menu and choose GAD: Check syntax. The compiler reads the file without running it.
  2. Choose GAD: Format to put the code in the official GAD style.
bilten.gad : sentaks la kòrèk (6 deklarasyon, 1 fichye).
  • Typed in the terminal: gad tcheke bilten.gad and gad fòmate bilten.gad.
  • gad fòmate bilten.gad --wè shows the formatted code without writing the file.

Read GAD in English

gad tradui shows a file with English keywords, for reading only. The language of the project stays Creole.

def mwayèn with nòt-yo
    fail "Pa gen okenn nòt pou kalkile." if nòt-yo empty
    return sonm(nòt-yo) / len nòt-yo
end
  • Typed in the terminal: gad tradui bilten.gad an.
  • Set GAD_LANG=en to get the error messages in English too.

The compiler commands

CommandWhat it does
gad kouri file.gadRun a program
gad bati file.gadBuild a Windows application
gad tcheke file.gadCheck the syntax without running
gad fòmate file.gadPut the code in the official style
gad tèsRun the tests
gad tradui file.gadRead a file with English keywords
gad pakeManage packages
gad vesyonShow the compiler version