summaryrefslogtreecommitdiff
path: root/userland/minibox/utilities/sh/lexer.h
blob: 65366dcb5bb220828c8ae5b4309db4961a270ed4 (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
28
#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_EQUAL,
  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