【发布时间】:2011-01-15 02:41:47
【问题描述】:
这是我的代码:
34
35 /**
36 ** \file position.hh
37 ** Define the example::position class.
38 */
39
40 #ifndef BISON_POSITION_HH
41 #define BISON_POSITION_HH
42
43 #include <iostream>
44 #include <string>
45
46 namespace example
47 {
48 /// Abstract a position.
49 class position
50 {
51 public:
52
53 /// Construct a position.
54 position ()
55 : filename (0), line (1), column (0)
56 {
谢谢,speeder,太好了。 Necrolis,也谢谢你。你们两个在编译单元上都在同一轨道上。这是完整的错误报告:
在 location.hh:45 包含的文件中, 来自 parser.h:64, 来自scanner.h:25, 来自scanner.ll:8: position.hh:46: 错误:“命名空间”之前的预期 unqualified-id
location.hh 看起来像这样:
35 /**
36 ** \file location.hh
37 ** Define the example::location class.
38 */
39
40 #ifndef BISON_LOCATION_HH
41 # define BISON_LOCATION_HH
42
43 # include <iostream>
44 # include <string>
45 # include "position.hh"
46
47 namespace example
48 {
49
50 /// Abstract a location.
51 class location
52 {
53 public:
我还应该补充一点,这些文件是由 bison 生成的。正是当我尝试编译由 flex++ 生成的 c++ 扫描程序类时,我才到了这个阶段。我通过发出 flex --c++ -oscanner.ccscanner.ll 来获取 .cc 代码。
【问题讨论】:
标签: c++ bison yacc flex-lexer