--- /dev/null
+bareC lexer documentation
+date: 20/02/2025
+=========================
+
+overview:
+---------
+the bareC lexer converts the raw source code into a stream of tokens that the
+parser can easily process. it reads the source file character-by-character,
+skips whitespace and comments (single-line only), and recognizes:
+ - keywords
+ - identifiers
+ - literals (integers)
+ - operators (+, -, /, *, ==, =, >)
+ - punctuation
+
+token types:
+------------
+the lexer recognizes the following token types:
+ - keywords: "int", "return", "if", "else", "while"
+ - identifiers: variable and function names
+ - literals: integer literals
+ - operators: "=", "==", ">", "+", "-", "/", "*"
+ - punctuation: "(", ")", "{", "}", ";", ","
+ - end-of-file: eof and unknown
+
+EBNF for lexical elements:
+--------------------------
+1. letters and digits:
+ <letter> = "A" | "B" | ... | "Z" | "a" | "b" | ... | "z" ;
+ <digit> = "0" | "1" | ... | "9" ;
+
+2. identifier:
+ <identifier> = ( <letter> | "_" ) { <letter> | <digit> | "_" } ;
+
+3. integer literal:
+ <number> = <digit> { <digit> };
+
+TODO: keywords, operators
+
+whitespace and comments:
+------------------------
+ - whitespace (space, tab, newline) is skipped
+ - single-line comments start with "//" and terminate at line end
+ - unrecognized returns as TK_UNKNOWN
+
+processing flow:
+----------------
+1. open the source file and prime the first character
+2. repeat:
+ - skip whitespace and comments
+ - check current character:
+ - if digit -> accumulate a number
+ - if letter or _, accumulate an identifier and check reserved
+ - match multi-character operators
+ - directly return tokens
+3. continue until EOF
+
if (g_currentChar == '{') { advance(); return makeToken(TK_LBRACE, "{"); }
if (g_currentChar == '}') { advance(); return makeToken(TK_RBRACE, "}"); }
if (g_currentChar == ';') { advance(); return makeToken(TK_SEMICOLON, ";"); }
+ if (g_currentChar == ',') { advance(); return makeToken(TK_COMMA, ","); }
if (g_currentChar == '>') { advance(); return makeToken(TK_GT, ">"); }
/* handle numeric literal */