Feature: Parser #8

Closed
opened 2023-09-23 05:54:03 +00:00 by j · 1 comment
Owner

Feature Progress

  • Decide on the language's grammar
    • Create production rules for expressions
    • Use these production rules to implement a function which turns a sequence of tokens into an AST
  • Implement function declaration syntax
  • Implement function call syntax
  • Implement variable declaration and definition syntax
  • Implement a temporary range syntax
  • Implement items
  • Implement static scopes/modules

Feature description

The Parser takes a sequence of tokens and uses them to construct an abstract syntax tree using the rules of the language's grammar.

Example

// This is a Conlang file. Conlang is an expression-based language designed for maximum flexibility etc. etc. whatever

// This is a function. It can be called with the call operator
fn main() {
    // This is a variable declaration
    let x = 100;

    let y = if x < 50 {
        // do a thing
        0
    } else {
        // do a different thing, and return the result of that
        x
    }

    // This is an example of a for loop using range syntax
    let z = for i in 0..y {
        // do a thing repeatedly, return the result of the last iteration
    }

    // TODO: decide how to do IO
}
# Feature Progress <!-- Describe the steps for implementing this feature in libconlang --> - [x] Decide on the language's grammar - [x] Create production rules for expressions - [x] Use these production rules to implement a function which turns a sequence of tokens into an AST - [x] Implement function declaration syntax - [x] Implement function call syntax - [x] Implement variable declaration and definition syntax - [x] Implement a temporary range syntax - [x] Implement items - [x] Implement static scopes/modules # Feature description <!-- [Feature name] does a cool thing that you should describe here --> The Parser takes a sequence of tokens and uses them to construct an abstract syntax tree using the rules of the language's grammar. # Example <!-- Demonstrate this feature with a clear, concise code example Right now, we're (ab)using Rust syntax highlighting, since it most closely matches what I'm currently aiming for --> ```rust // This is a Conlang file. Conlang is an expression-based language designed for maximum flexibility etc. etc. whatever // This is a function. It can be called with the call operator fn main() { // This is a variable declaration let x = 100; let y = if x < 50 { // do a thing 0 } else { // do a different thing, and return the result of that x } // This is an example of a for loop using range syntax let z = for i in 0..y { // do a thing repeatedly, return the result of the last iteration } // TODO: decide how to do IO } ```
j added the
enhancement
label 2023-09-23 05:54:03 +00:00
j self-assigned this 2023-09-23 05:54:03 +00:00
j added this to the Basic Syntax project 2023-09-23 05:54:03 +00:00
j added a new dependency 2023-09-23 05:54:20 +00:00
j pinned this 2023-09-23 05:58:10 +00:00
Author
Owner

Parser is pretty much complete, now. Conlang has a basic grammar, a tree-walk interpreter which can handle a minimal subset of that grammar, and even a few programs to its name!

Parser is pretty much complete, now. Conlang has a basic grammar, a tree-walk interpreter which can handle a minimal subset of that grammar, and even a few programs to its name!
j closed this issue 2024-03-01 09:11:30 +00:00
j unpinned this 2024-03-01 09:13:54 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Depends on
Reference: j/Conlang#8
No description provided.