From 5884aa1a5c84c73b54db321444282c1d1c65e597 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 4 Mar 2021 15:34:25 -0800 Subject: [PATCH] Give syntax files more useful and mnemonic names. Distinguishes parts that come from the parser and lexer. It used to be that all the files were called "syntax*", but lexing and parsing are distinct phases that are easier to keep track of when distinguished. syntax.yy.cpp being the source file generated by flex, containing the lexer was particularly confusing, because the yy tends to indicate it is a yacc/Bison product, and the ".tab." substring, indicating "tables" is not really useful to the developer. These names also match up with what Bison's C++ example uses, which will make the transition easier. --- executable_semantics/syntax/BUILD | 26 +++++++++---------- .../syntax/{syntax.lpp => lexer.lpp} | 2 +- .../syntax/{syntax.ypp => parser.ypp} | 0 3 files changed, 14 insertions(+), 14 deletions(-) rename executable_semantics/syntax/{syntax.lpp => lexer.lpp} (97%) rename executable_semantics/syntax/{syntax.ypp => parser.ypp} (100%) diff --git a/executable_semantics/syntax/BUILD b/executable_semantics/syntax/BUILD index 0d13a31ee9bb..60b4e3589389 100644 --- a/executable_semantics/syntax/BUILD +++ b/executable_semantics/syntax/BUILD @@ -12,12 +12,12 @@ package(default_visibility = ["//executable_semantics:__subpackages__"]) cc_library( name = "syntax", srcs = [ - "syntax.tab.cpp", - "syntax.yy.cpp", + "lexer.cpp", + "parser.cpp", "syntax_helpers.cpp", "syntax_helpers.h", ], - hdrs = ["syntax.tab.h"], + hdrs = ["parser.h"], # Disable warnings for generated code. copts = [ "-Wno-unneeded-internal-declaration", @@ -35,15 +35,15 @@ cc_library( genrule( name = "syntax_bison_srcs", - srcs = ["syntax.ypp"], + srcs = ["parser.ypp"], outs = [ - "syntax.tab.cpp", - "syntax.tab.h", + "parser.cpp", + "parser.h", ], cmd = "M4=$(M4) $(BISON) " + - "--output=$(location syntax.tab.cpp) " + - "--defines=$(location syntax.tab.h) " + - "$(location syntax.ypp)", + "--output=$(location parser.cpp) " + + "--defines=$(location parser.h) " + + "$(location parser.ypp)", toolchains = [ "@rules_bison//bison:current_bison_toolchain", "@rules_m4//m4:current_m4_toolchain", @@ -52,11 +52,11 @@ genrule( genrule( name = "syntax_flex_srcs", - srcs = ["syntax.lpp"], - outs = ["syntax.yy.cpp"], + srcs = ["lexer.lpp"], + outs = ["lexer.cpp"], cmd = "M4=$(M4) $(FLEX) " + - "--outfile=$(location syntax.yy.cpp) " + - "$(location syntax.lpp)", + "--outfile=$(location lexer.cpp) " + + "$(location lexer.lpp)", toolchains = [ "@rules_flex//flex:current_flex_toolchain", "@rules_m4//m4:current_m4_toolchain", diff --git a/executable_semantics/syntax/syntax.lpp b/executable_semantics/syntax/lexer.lpp similarity index 97% rename from executable_semantics/syntax/syntax.lpp rename to executable_semantics/syntax/lexer.lpp index e1a934da97cb..06102b2c510e 100644 --- a/executable_semantics/syntax/syntax.lpp +++ b/executable_semantics/syntax/lexer.lpp @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception %{ #include -#include "executable_semantics/syntax/syntax.tab.h" +#include "executable_semantics/syntax/parser.h" %} /* Turn off legacy bits we don't need */ diff --git a/executable_semantics/syntax/syntax.ypp b/executable_semantics/syntax/parser.ypp similarity index 100% rename from executable_semantics/syntax/syntax.ypp rename to executable_semantics/syntax/parser.ypp