summaryrefslogtreecommitdiff
path: root/userland/minibox/utilities/sh/lexer.h
blob: 4a7e61cdd03068f13c50428e5c037c73d7fc1642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef LEXER_H
#define LEXER_H
#include <stddef.h>
#include <tb/sv.h>

typedef enum {
  TOKEN_CHARS,
  TOKEN_AND,
  TOKEN_NOT,
  TOKEN_NOOP,
  TOKEN_PIPE,
  TOKEN_STREAM,
  TOKEN_STREAM_APPEND,
  TOKEN_BACKGROUND,
  TOKEN_NEWLINE,
} token_type_t;

struct TOKEN {
  token_type_t type;
  struct sv string_rep;
  struct TOKEN *next;
};

struct TOKEN *lex(struct sv code);
struct AST *generate_ast(struct TOKEN *token);
void free_tokens(struct TOKEN *token);
#endif // LEXER_H