diff options
author | Adela Vais <adela.vais99@gmail.com> | 2021-01-25 17:59:06 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2021-01-30 08:49:22 +0100 |
commit | 689b1849837075c20254df6bfbb5e7a7da1bc6a5 (patch) | |
tree | 2fcbfb8a6eae64c7f50bec93e4047c4754c61ae3 /tests/scanner.at | |
parent | b4582f1918ee3ae2a797276b4b56500702aa8fc8 (diff) | |
download | bison-689b1849837075c20254df6bfbb5e7a7da1bc6a5.tar.gz |
d: tests: various style fixes
* tests/calc.at, tests/scanner.at: Here.
(yylex): Report values directly, without storing them to the union
first.
Diffstat (limited to 'tests/scanner.at')
-rw-r--r-- | tests/scanner.at | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/tests/scanner.at b/tests/scanner.at index d2c13a9e..852e7c9a 100644 --- a/tests/scanner.at +++ b/tests/scanner.at @@ -94,7 +94,7 @@ m4_define([AT_RAW_YYLEX(d)], import std.stdio; auto yyLexer(R)(R range) - if (isInputRange!R && is (ElementType!R : dchar)) +if (isInputRange!R && is (ElementType!R : dchar)) { return new YYLexer!R(range); } @@ -105,18 +105,14 @@ auto yyLexer () } class YYLexer(R) : Lexer - if (isInputRange!R && is (ElementType!R : dchar)) +if (isInputRange!R && is (ElementType!R : dchar)) { R input; - this(R r) { - input = r; - } + this(R r) { input = r; } ]AT_YYERROR_DEFINE[ - Value value_; - Symbol yylex () { import std.uni : isNumber; @@ -131,8 +127,7 @@ class YYLexer(R) : Lexer switch (c) { case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - value_.val = c - '0'; - return Symbol(TokenKind.NUM, value_.val); + return Symbol(TokenKind.NUM, c - '0'); case '+': return Symbol(TokenKind.PLUS); case '-': return Symbol(TokenKind.MINUS); case '*': return Symbol(TokenKind.STAR); |