YASH 0.1
CLI written in C
Loading...
Searching...
No Matches
parse.c File Reference

Parse functions for the YASH shell. More...

#include "../include/parse.h"
#include "../include/debug.h"
#include "../include/yash.h"
#include <stdio.h>
#include <string.h>

Functions

void init_command (Command *cmd)
 Initialize a Command structure to NULL/0 values.
 
int parse_line (char *line, Line *line_out)
 Parse a line of input and store the result in line_out.
 
int tokenize_line (char *line, char *tokens[], int *num_tokens)
 Tokenize a line of input and store the result in tokens.
 

Detailed Description

Parse functions for the YASH shell.

Author
Nathan Lemma
Date
09-16-2025

This file contains the parse functions for the YASH shell.

Function Documentation

◆ init_command()

void init_command ( Command * cmd)

Initialize a Command structure to NULL/0 values.

Parameters
cmdPointer to Command structure to initialize

◆ parse_line()

int parse_line ( char * line,
Line * line_out )

Parse a line of input and store the result in line_out.

Parameters
lineAssume the string is properly null-terminated, no newline characters and no more than 2000 characters (i.e. no more than MAX_CMDLINE - 1 characters)
line_out
Returns
0 on success, -1 on invalid

◆ tokenize_line()

int tokenize_line ( char * line,
char * tokens[],
int * num_tokens )

Tokenize a line of input and store the result in tokens.

Note
Caller must pass a mutable buffer (i.e. not a string literal)
Parameters
lineAssume the string is properly null-terminated, no newline characters and no more than 2000 characters (i.e. no more than MAX_CMDLINE - 1 characters)
tokens
num_tokens
Returns
0 on success, -1 on invalid