mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
d: examples: fix coding style
* examples/d/calc/calc.y, examples/d/simple/calc.y: Fix whitespace issues and remove the @property attribute.
This commit is contained in:
committed by
Akim Demaille
parent
5a31cda4c3
commit
4252134ba4
@@ -72,12 +72,12 @@ import std.range.primitives;
|
|||||||
import std.stdio;
|
import std.stdio;
|
||||||
|
|
||||||
auto calcLexer(R)(R range)
|
auto calcLexer(R)(R range)
|
||||||
if (isInputRange!R && is (ElementType!R : dchar))
|
if (isInputRange!R && is(ElementType!R : dchar))
|
||||||
{
|
{
|
||||||
return new CalcLexer!R(range);
|
return new CalcLexer!R(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto calcLexer (File f)
|
auto calcLexer(File f)
|
||||||
{
|
{
|
||||||
import std.algorithm : map, joiner;
|
import std.algorithm : map, joiner;
|
||||||
import std.utf : byDchar;
|
import std.utf : byDchar;
|
||||||
@@ -89,7 +89,7 @@ auto calcLexer (File f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CalcLexer(R) : Lexer
|
class CalcLexer(R) : Lexer
|
||||||
if (isInputRange!R && is (ElementType!R : dchar))
|
if (isInputRange!R && is(ElementType!R : dchar))
|
||||||
{
|
{
|
||||||
R input;
|
R input;
|
||||||
|
|
||||||
@@ -109,17 +109,17 @@ class CalcLexer(R) : Lexer
|
|||||||
|
|
||||||
YYSemanticType semanticVal_;
|
YYSemanticType semanticVal_;
|
||||||
|
|
||||||
public final @property YYSemanticType semanticVal ()
|
public final YYSemanticType semanticVal()
|
||||||
{
|
{
|
||||||
return semanticVal_;
|
return semanticVal_;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenKind yylex ()
|
TokenKind yylex()
|
||||||
{
|
{
|
||||||
import std.uni : isWhite, isNumber;
|
import std.uni : isWhite, isNumber;
|
||||||
|
|
||||||
// Skip initial spaces
|
// Skip initial spaces
|
||||||
while (!input.empty && input.front != '\n' && isWhite (input.front))
|
while (!input.empty && input.front != '\n' && isWhite(input.front))
|
||||||
{
|
{
|
||||||
start = end;
|
start = end;
|
||||||
end.column++;
|
end.column++;
|
||||||
@@ -180,10 +180,10 @@ class CalcLexer(R) : Lexer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main ()
|
int main()
|
||||||
{
|
{
|
||||||
auto l = calcLexer (stdin);
|
auto l = calcLexer(stdin);
|
||||||
auto p = new Calc (l);
|
auto p = new Calc(l);
|
||||||
p.parse ();
|
p.parse();
|
||||||
return l.exit_status;
|
return l.exit_status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,12 +70,12 @@ import std.range.primitives;
|
|||||||
import std.stdio;
|
import std.stdio;
|
||||||
|
|
||||||
auto calcLexer(R)(R range)
|
auto calcLexer(R)(R range)
|
||||||
if (isInputRange!R && is (ElementType!R : dchar))
|
if (isInputRange!R && is(ElementType!R : dchar))
|
||||||
{
|
{
|
||||||
return new CalcLexer!R(range);
|
return new CalcLexer!R(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto calcLexer (File f)
|
auto calcLexer(File f)
|
||||||
{
|
{
|
||||||
import std.algorithm : map, joiner;
|
import std.algorithm : map, joiner;
|
||||||
import std.utf : byDchar;
|
import std.utf : byDchar;
|
||||||
@@ -87,7 +87,7 @@ auto calcLexer (File f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CalcLexer(R) : Lexer
|
class CalcLexer(R) : Lexer
|
||||||
if (isInputRange!R && is (ElementType!R : dchar))
|
if (isInputRange!R && is(ElementType!R : dchar))
|
||||||
{
|
{
|
||||||
R input;
|
R input;
|
||||||
|
|
||||||
@@ -96,25 +96,25 @@ class CalcLexer(R) : Lexer
|
|||||||
// Should be a local in main, shared with %parse-param.
|
// Should be a local in main, shared with %parse-param.
|
||||||
int exit_status = 0;
|
int exit_status = 0;
|
||||||
|
|
||||||
public void yyerror (string s)
|
public void yyerror(string s)
|
||||||
{
|
{
|
||||||
exit_status = 1;
|
exit_status = 1;
|
||||||
stderr.writeln (s);
|
stderr.writeln(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
YYSemanticType semanticVal_;
|
YYSemanticType semanticVal_;
|
||||||
|
|
||||||
public final @property YYSemanticType semanticVal ()
|
public final YYSemanticType semanticVal()
|
||||||
{
|
{
|
||||||
return semanticVal_;
|
return semanticVal_;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenKind yylex ()
|
TokenKind yylex()
|
||||||
{
|
{
|
||||||
import std.uni : isWhite, isNumber;
|
import std.uni : isWhite, isNumber;
|
||||||
|
|
||||||
// Skip initial spaces
|
// Skip initial spaces
|
||||||
while (!input.empty && input.front != '\n' && isWhite (input.front))
|
while (!input.empty && input.front != '\n' && isWhite(input.front))
|
||||||
input.popFront;
|
input.popFront;
|
||||||
|
|
||||||
if (input.empty)
|
if (input.empty)
|
||||||
@@ -145,10 +145,10 @@ class CalcLexer(R) : Lexer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main ()
|
int main()
|
||||||
{
|
{
|
||||||
auto l = calcLexer (stdin);
|
auto l = calcLexer(stdin);
|
||||||
auto p = new Calc (l);
|
auto p = new Calc(l);
|
||||||
p.parse ();
|
p.parse();
|
||||||
return l.exit_status;
|
return l.exit_status;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user