diff options
author | Adela Vais <adela.vais99@gmail.com> | 2021-01-16 15:20:09 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2021-01-17 08:38:51 +0100 |
commit | 5aaa93ae727cb396b85d0c9875e0f61020f259eb (patch) | |
tree | 80559c5905d296d83f17f0a041ecd65e7878a079 /examples | |
parent | cd99a1a923c652c4fc4fec8a6bc6f0db83b8b787 (diff) | |
download | bison-5aaa93ae727cb396b85d0c9875e0f61020f259eb.tar.gz |
d: examples: calc: remove Value from Lexer
The Symbol constructor does not use it, so it is easier to not use
Value at all.
* examples/d/calc/calc.y: Here.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/d/calc/calc.y | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/d/calc/calc.y b/examples/d/calc/calc.y index 640e246a..83e378e4 100644 --- a/examples/d/calc/calc.y +++ b/examples/d/calc/calc.y @@ -108,8 +108,6 @@ if (isInputRange!R && is(ElementType!R : dchar)) stderr.writeln(loc.toString(), ": ", s); } - Value value_; - Symbol yylex() { import std.uni : isWhite, isNumber; @@ -128,6 +126,7 @@ if (isInputRange!R && is(ElementType!R : dchar)) // Numbers. if (input.front.isNumber) { + int ival; int lenChars = 0; import std.compiler : version_minor; static if (version_minor >= 95) @@ -137,14 +136,14 @@ if (isInputRange!R && is(ElementType!R : dchar)) import std.typecons : Flag, Yes; import std.conv : parse; auto parsed = parse!(int, R, Yes.doCount)(input); - value_.ival = parsed.data; + ival = parsed.data; lenChars = cast(int) parsed.count; } else { auto copy = input; import std.conv : parse; - value.ival = input.parse!int; + ival = input.parse!int; while (!input.empty && copy.front != input.front) { lenChars++; @@ -153,7 +152,7 @@ if (isInputRange!R && is(ElementType!R : dchar)) } location.begin = location.end; location.end.column += lenChars; - return Symbol(TokenKind.NUM, value_.ival, location); + return Symbol(TokenKind.NUM, ival, location); } // Individual characters |