Purple
0.1
Standard Language Specification
|
Functions for lexical scanning from input source files. More...
#include <math.h>
#include <string.h>
#include "data.h"
#include "scan.h"
#include "utils/logging.h"
Functions | |
char | next (void) |
Get the next valid character from the current input file. More... | |
void | put_back_into_stream (char c) |
Put a character back into the input stream. More... | |
static char | skip_whitespace (void) |
Skips whitespace tokens. More... | |
static int | index_of (char *s, int c) |
Return the index of char c in string s. More... | |
static int | char_to_int (char c, int base) |
Convert a character into its integer form. More... | |
static Number | parse_number_literal (char *literal, int length, int base) |
static Number | scan_number_literal (char c) |
Scan and return an integer literal from the input stream. More... | |
static char | scan_char_literal (char c) |
Scan and return an integer literal from the input stream. More... | |
static bool | is_valid_identifier_char (char c, int index) |
Determine if a character in an identifier is a permitted character. More... | |
static int | scan_identifier (char c, char *buf, int max_len) |
Scan an alphanumeric identifier. More... | |
static TokenType | parse_keyword (char *keyword_string) |
Retrieve the TokenType value corresponding to a keyword string. More... | |
static bool | scan_check_integer_literal (char c) |
Check if the current character is the start of an integer literal. More... | |
static bool | scan_check_char_literal (char c) |
Check if the current character is the start of a character literal. More... | |
static bool | scan_check_keyword_identifier (char c) |
Check if the current character is the start of a keyword or identifier. More... | |
bool | scan () |
Scan tokens into the Token struct. More... | |
Functions for lexical scanning from input source files.
|
static |
Convert a character into its integer form.
c | Character to convert |
base | Base to convert to, or -1 if no limit |
|
static |
Return the index of char c in string s.
s | String to search in |
c | Character to search for |
|
static |
Determine if a character in an identifier is a permitted character.
c | Character to check |
index | Index of character in identifier string |
char next | ( | void | ) |
Get the next valid character from the current input file.
|
static |
Retrieve the TokenType value corresponding to a keyword string.
keyword_string | String to convert to TokenType |
|
static |
void put_back_into_stream | ( | char | c | ) |
Put a character back into the input stream.
c | Character to be placed into the input stream |
bool scan | ( | ) |
|
static |
Scan and return an integer literal from the input stream.
c | Current character |
|
static |
Check if the current character is the start of a character literal.
c |
|
static |
Check if the current character is the start of an integer literal.
c | Character to check |
|
static |
Check if the current character is the start of a keyword or identifier.
c | Character to check |
|
static |
Scan an alphanumeric identifier.
c | First character in identifier |
buf | Buffer to read identifier into |
max_len | Maximum length of the identifier |
|
static |
Scan and return an integer literal from the input stream.
c | Current character |
|
static |
Skips whitespace tokens.