Ellex Grammar Reference
Ellex Grammar Reference
Section titled “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.
Overview of Ellex Syntax
Section titled “Overview of Ellex Syntax”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.
Core Commands
Section titled “Core Commands”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?" → nametell "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?" → agewhen {age} > 10:tell "You're older than 10!"else:tell "You're 10 or younger."
Modal Commands
Section titled “Modal Commands”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.
Turtle Graphics
Section titled “Turtle Graphics”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.
Grammar Definition
Section titled “Grammar Definition”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.
Visualizing Grammar with D2 Diagrams
Section titled “Visualizing Grammar with D2 Diagrams”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 StructureProgram -> Commands: containsProgram -> Modes: usesCommands -> NaturalLanguage: includesCommands -> TurtleGraphics: includesNaturalLanguage -> Output: e.g., tellNaturalLanguage -> Input: e.g., askNaturalLanguage -> Loops: e.g., repeatNaturalLanguage -> Functions: e.g., makeNaturalLanguage -> Conditionals: e.g., whenModes -> Listen: @listenModes -> Think: @thinkModes -> Build: @build
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.
Contributing to Grammar Development
Section titled “Contributing to Grammar Development”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!