Skip to content

Ellex Grammar Reference

Welcome to the grammar reference for Ellex, a natural language programming environment designed for young learners. This page provides an overview of the syntax and structure of the Ellex language. As the language evolves, detailed grammar definitions will be added here.

Ellex is built around the principle of natural language programming, where code reads like everyday speech. This makes it intuitive for beginners, especially children aged 6-16, to start coding without the burden of complex syntax rules.

Key features of Ellex syntax include:

  • Natural Language Commands: Instructions that mimic spoken language, such as tell "Hello!" to output text.
  • Modal Programming: Different interaction modes like @speak, @listen, @think, and @build to structure the coding process.
  • Safety Mechanisms: Built-in constraints on execution to prevent errors and crashes.
  • Progressive Disclosure: Start with simple commands and gradually introduce full Elixir syntax for advanced programming.

Below are some of the fundamental commands in Ellex, which form the basis of its grammar:

  • Output Text: Use tell to display messages.
    tell "Welcome to Ellex!"
  • Input from User: Use ask to request input and store it in a variable.
    ask "What's your name?" → name
    tell "Hello, {name}!"
  • Loops: Use repeat for iteration.
    repeat 3 times:
    tell "This is loop iteration."
  • Functions: Define reusable blocks with make.
    make say_hello:
    tell "Hello, everyone!"
    call say_hello
  • Conditionals: Use when for decision-making.
    ask "How old are you?" → age
    when {age} > 10:
    tell "You're older than 10!"
    else:
    tell "You're 10 or younger."

Ellex supports modal programming to help users interact with the environment in different ways:

  • @listen: Exploration mode for searching or selecting.
  • @think: Query mode for understanding or analyzing.
  • @build: Creation mode for refactoring or extracting code.

Ellex includes a built-in turtle graphics system for visual programming. Commands include:

  • move forward 50: Move the turtle forward by 50 units.
  • turn right 90: Turn the turtle right by 90 degrees.
  • use color red: Set the drawing color to red.
  • draw circle with radius 20: Draw a circle with a radius of 20 units.

Note: The formal grammar definition for Ellex (e.g., using Pest or Nom parsers as planned in the project roadmap) is currently under development. Once finalized, this section will include detailed parsing rules and syntax trees to help advanced users and contributors understand the underlying structure of the language.

In the meantime, Ellex’s natural language syntax is designed to be intuitive. The examples above cover the primary constructs you’ll use in programming with Ellex.

To aid in understanding the structure of Ellex, we plan to include D2 diagrams that visually represent the grammar rules and language components. Below is a conceptual D2 diagram description for the overall structure of an Ellex program. Once rendering support is fully integrated, these will be displayed as images.

Conceptual D2 Diagram for Ellex Program Structure

Section titled “Conceptual D2 Diagram for Ellex Program Structure”
# Ellex Program Structure
Program -> Commands: contains
Program -> Modes: uses
Commands -> NaturalLanguage: includes
Commands -> TurtleGraphics: includes
NaturalLanguage -> Output: e.g., tell
NaturalLanguage -> Input: e.g., ask
NaturalLanguage -> Loops: e.g., repeat
NaturalLanguage -> Functions: e.g., make
NaturalLanguage -> Conditionals: e.g., when
Modes -> Listen: @listen
Modes -> Think: @think
Modes -> Build: @build

Diagram for reference-grammar-d2-84 Diagram for reference-grammar-d2-84

Note: The D2 diagram below is automatically rendered as an image during the build process. If you’re viewing this documentation locally, ensure you run npm run build or npm run render-diagrams to generate the images.

If you’re interested in contributing to the formalization of Ellex’s grammar, visit our GitHub repository for details on the parser and grammar roadmap. The project uses Rust-based parsing libraries like Pest or Nom for grammar definition, and your input can help shape how Ellex interprets code.

Check back soon for updates as we continue to refine and document the Ellex language grammar!