From 492f6e6b1c8d062c6732f9aa3360c14708bb1452 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 30 Dec 2017 20:56:54 +0300 Subject: Lexer: angle brackets --- grammar.ron | 2 ++ src/lexer/mod.rs | 2 ++ src/syntax_kinds.rs | 30 +++++++++++++++++------------- tests/data/lexer/0005_symbols.rs | 2 +- tests/data/lexer/0005_symbols.txt | 4 ++++ 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/grammar.ron b/grammar.ron index 4c9291dfb..b707248f3 100644 --- a/grammar.ron +++ b/grammar.ron @@ -18,6 +18,8 @@ Grammar( "R_CURLY", "L_BRACK", "R_BRACK", + "L_ANGLE", + "R_ANGLE", "AT", "POUND", "TILDE", diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index 5255c3d56..24c14add0 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -47,6 +47,8 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { '}' => return R_CURLY, '[' => return L_BRACK, ']' => return R_BRACK, + '<' => return L_ANGLE, + '>' => return R_ANGLE, '@' => return AT, '#' => return POUND, '~' => return TILDE, diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index a922056ce..040ac1257 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs @@ -19,20 +19,22 @@ pub const L_CURLY: SyntaxKind = SyntaxKind(14); pub const R_CURLY: SyntaxKind = SyntaxKind(15); pub const L_BRACK: SyntaxKind = SyntaxKind(16); pub const R_BRACK: SyntaxKind = SyntaxKind(17); -pub const AT: SyntaxKind = SyntaxKind(18); -pub const POUND: SyntaxKind = SyntaxKind(19); -pub const TILDE: SyntaxKind = SyntaxKind(20); -pub const QUESTION: SyntaxKind = SyntaxKind(21); -pub const COLON: SyntaxKind = SyntaxKind(22); -pub const COLONCOLON: SyntaxKind = SyntaxKind(23); -pub const DOLLAR: SyntaxKind = SyntaxKind(24); -pub const EQ: SyntaxKind = SyntaxKind(25); -pub const EQEQ: SyntaxKind = SyntaxKind(26); -pub const FAT_ARROW: SyntaxKind = SyntaxKind(27); -pub const NEQ: SyntaxKind = SyntaxKind(28); -pub const NOT: SyntaxKind = SyntaxKind(29); +pub const L_ANGLE: SyntaxKind = SyntaxKind(18); +pub const R_ANGLE: SyntaxKind = SyntaxKind(19); +pub const AT: SyntaxKind = SyntaxKind(20); +pub const POUND: SyntaxKind = SyntaxKind(21); +pub const TILDE: SyntaxKind = SyntaxKind(22); +pub const QUESTION: SyntaxKind = SyntaxKind(23); +pub const COLON: SyntaxKind = SyntaxKind(24); +pub const COLONCOLON: SyntaxKind = SyntaxKind(25); +pub const DOLLAR: SyntaxKind = SyntaxKind(26); +pub const EQ: SyntaxKind = SyntaxKind(27); +pub const EQEQ: SyntaxKind = SyntaxKind(28); +pub const FAT_ARROW: SyntaxKind = SyntaxKind(29); +pub const NEQ: SyntaxKind = SyntaxKind(30); +pub const NOT: SyntaxKind = SyntaxKind(31); -static INFOS: [SyntaxInfo; 30] = [ +static INFOS: [SyntaxInfo; 32] = [ SyntaxInfo { name: "ERROR" }, SyntaxInfo { name: "IDENT" }, SyntaxInfo { name: "UNDERSCORE" }, @@ -51,6 +53,8 @@ static INFOS: [SyntaxInfo; 30] = [ SyntaxInfo { name: "R_CURLY" }, SyntaxInfo { name: "L_BRACK" }, SyntaxInfo { name: "R_BRACK" }, + SyntaxInfo { name: "L_ANGLE" }, + SyntaxInfo { name: "R_ANGLE" }, SyntaxInfo { name: "AT" }, SyntaxInfo { name: "POUND" }, SyntaxInfo { name: "TILDE" }, diff --git a/tests/data/lexer/0005_symbols.rs b/tests/data/lexer/0005_symbols.rs index 00ed44b65..c41e985a1 100644 --- a/tests/data/lexer/0005_symbols.rs +++ b/tests/data/lexer/0005_symbols.rs @@ -1,4 +1,4 @@ -; , ( ) { } [ ] @ # ~ ? $ +; , ( ) { } [ ] < > @ # ~ ? $ . .. ... ..= : :: = => diff --git a/tests/data/lexer/0005_symbols.txt b/tests/data/lexer/0005_symbols.txt index 291872026..a1b777a92 100644 --- a/tests/data/lexer/0005_symbols.txt +++ b/tests/data/lexer/0005_symbols.txt @@ -14,6 +14,10 @@ L_BRACK 1 "[" WHITESPACE 1 " " R_BRACK 1 "]" WHITESPACE 1 " " +L_ANGLE 1 "<" +WHITESPACE 1 " " +R_ANGLE 1 ">" +WHITESPACE 1 " " AT 1 "@" WHITESPACE 1 " " POUND 1 "#" -- cgit v1.2.3