0xa48rx394r83e9 / Nutri-lang

Nutri-lang is an educational programming language designed to showcase the inner workings and concepts behind interpretive languages. It serves as a simple and straightforward example to demonstrate how source code is parsed, interpreted, and executed in a step-by-step manner.
1 stars 0 forks source link

Language Specification #1

Closed 0xa48rx394r83e9 closed 5 months ago

0xa48rx394r83e9 commented 5 months ago
0xa48rx394r83e9 commented 5 months ago
  1. ๐Ÿ“š Define the Language Specification
    • Syntax and Grammar:
    • Variables: var x = 10;
    • Arithmetic operations: +, -, *, /
    • Comparison operators: ==, !=, <, >, <=, >=
    • Control flow: if, else, while, for
    • Functions: func add(a, b) { return a + b; }
    • Data Types: int, float, bool, string
  2. ๐Ÿงฉ Choose a Parsing Technique
    • We'll use a recursive descent parser for simplicity.
    • Lexical structure:
    • Keywords: var, if, else, while, for, func, return
    • Identifiers: Alphanumeric characters and underscores, starting with a letter or underscore.
    • Literals: Integers, floating-point numbers, booleans (true, false), strings (enclosed in double quotes).
    • Operators: +, -, *, /, ==, !=, <, >, <=, >=, =
    • Delimiters: (, ), {, }, ;
  3. ๐Ÿ› ๏ธ Implement the Lexer and Parser
    • Lexer
    • Parser
  4. ๐ŸŒณ Design the Abstract Syntax Tree (AST)
    • Define AST node classes:
  5. ๐Ÿงช Implement Semantic Analysis
    • Perform type checking and variable scoping:
  6. ๐ŸŽฏ Code Generation or Interpretation
    • We'll create an interpreter to execute the AST:
  7. ๐Ÿงช Testing and Refinement
    • Write test cases to cover various language features and edge cases:
  8. ๐Ÿ“– Documentation and Tooling
    • Document the language syntax, semantics, and usage guidelines.
    • Develop a command-line interface (CLI) to run the interpreter: