SpecificationLexical
Sourcelexer.d
Documentationhttps://dlang.org/phobos/dmd_lexer.html
CompileEnv;versionNumber;date;time;vendor;timestamp;previewIn;transitionIn;ddocOutput;masm;cCharLookupTable;dCharLookupTable;Lexer;fprintf(stderr,"Lexer.unittest %d\n",__LINE__);ErrorSink errorSink =new ErrorSinkStderr;void test(T)(string sequence, T expected,bool Ccompile =false){auto p =cast(const(char)*)sequence.ptr;dchar c2;Lexer lexer =newLexer(errorSink);assert(expected == lexer.escapeSequence(Loc.initial, p, Ccompile, c2));assert(p == sequence.ptr + sequence.length);}test(`'`, '\'');test(`"`, '"');test(`?`, '?');test(`\`, '\\');test(`0`, '\0');test(`a`, '\a');test(`b`, '\b');test(`f`, '\f');test(`n`, '\n');test(`r`, '\r');test(`t`, '\t');test(`v`, '\v');test(`x00`, 0x00);test(`xff`, 0xff);test(`xFF`, 0xff);test(`xa7`, 0xa7);test(`x3c`, 0x3c);test(`xe2`, 0xe2);test(`1`, '\1');test(`42`, '\42');test(`357`, '\357');test(`u1234`, '\u1234');test(`uf0e4`, '\uf0e4');test(`U0001f603`, '\U0001f603');test(`"`, '"');test(`<`, '<');test(`>`, '>');
charLookup;Ccompile;boolsize;shortsize;intsize;longsize;long_longsize;long_doublesize;wchar_tsize;eSink;compileEnv;filename, const(char)*base, size_tbegoffset, size_tendoffset, booldoDocComment, boolcommentToken, ErrorSinkerrorSink, const CompileEnv*compileEnv) scope;const(char)*filename | used for error messages |
const(char)*base | source code, must be terminated by a null (0) or EOF (0x1A) character |
size_tbegoffset | starting offset into base[] |
size_tendoffset | the last offset to read into base[] |
booldoDocComment | handle documentation comments |
boolcommentToken | comments become TOK.comment's |
ErrorSinkerrorSink | where error messages go, must not be null |
CompileEnv*compileEnv | version, vendor, date, time, etc. |
filename, const(char)*base, size_tbegoffset, size_tendoffset, booldoDocComment, boolcommentToken, boolwhitespaceToken, ErrorSinkerrorSink, const CompileEnv*compileEnv = null);whitespaceTokenerrorSink) scope;resetDefineLines(const(char)[]slice);nextDefineLine();empty() const;allocateToken();peekNext();peekNext2();scan(Token*t);Token*t | the token to set the resulting Token to |
peekPastParen(Token*tk);hexStringConstant(Token*t);parseSpecialTokenSequence();poundLine(ref Tokentok, boollinemarker);Tokentok | token we're on, which is linnum of linemarker |
boollinemarker | true if line marker format and lexer is on linnum |
Referenceslinemarkerhttps://gcc.gnu.org/onlinedocs/gcc-11.1.0/cpp/Preprocessor-Output.html
skipToNextLine(OutBuffer*defines = null);OutBuffer*defines | send characters todefines |
combineComments(const(char)[]c1, const(char)[]c2, boolnewParagraph);printRestOfTokens();