├── .gitattributes
├── .gitignore
├── LexAnaly
├── 20160425220522607.jpg
├── Debug
│ ├── 词法分析.ilk
│ └── 词法分析.pdb
├── 词法分析.opensdf
├── 词法分析.sdf
├── 词法分析.sln
├── 词法分析.v12.suo
└── 词法分析
│ ├── Base.cpp
│ ├── Base.h
│ ├── Debug
│ ├── vc120.idb
│ ├── vc120.pdb
│ ├── 词法分析.Build.CppClean.log
│ ├── 词法分析.log
│ └── 词法分析.tlog
│ │ ├── CL.read.1.tlog
│ │ ├── CL.write.1.tlog
│ │ ├── cl.command.1.tlog
│ │ ├── link.command.1.tlog
│ │ ├── link.read.1.tlog
│ │ ├── link.write.1.tlog
│ │ └── 词法分析.lastbuildstate
│ ├── LexAn.cpp
│ ├── LexAn.h
│ ├── in.txt
│ ├── main.cpp
│ ├── out.txt
│ ├── 词法分析.vcxproj
│ └── 词法分析.vcxproj.filters
├── README.md
└── grammar
├── Debug
├── 语法.ilk
└── 语法.pdb
├── 语法.sdf
├── 语法.sln
├── 语法.v12.suo
└── 语法
├── Base.cpp
├── Base.h
├── Debug
├── vc120.idb
├── vc120.pdb
├── 语法.Build.CppClean.log
├── 语法.log
└── 语法.tlog
│ ├── CL.read.1.tlog
│ ├── CL.write.1.tlog
│ ├── cl.command.1.tlog
│ ├── link.command.1.tlog
│ ├── link.read.1.tlog
│ ├── link.write.1.tlog
│ └── 语法.lastbuildstate
├── TableStack.cpp
├── TableStack.h
├── main.cpp
├── output.txt
├── product.txt
├── 语法.vcxproj
└── 语法.vcxproj.filters
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Precompiled Headers
8 | *.gch
9 | *.pch
10 |
11 | # Compiled Dynamic libraries
12 | *.so
13 | *.dylib
14 | *.dll
15 |
16 | # Fortran module files
17 | *.mod
18 |
19 | # Compiled Static libraries
20 | *.lai
21 | *.la
22 | *.a
23 | *.lib
24 |
25 | # Executables
26 | *.exe
27 | *.out
28 | *.app
29 |
30 | # =========================
31 | # Operating System Files
32 | # =========================
33 |
34 | # OSX
35 | # =========================
36 |
37 | .DS_Store
38 | .AppleDouble
39 | .LSOverride
40 |
41 | # Thumbnails
42 | ._*
43 |
44 | # Files that might appear in the root of a volume
45 | .DocumentRevisions-V100
46 | .fseventsd
47 | .Spotlight-V100
48 | .TemporaryItems
49 | .Trashes
50 | .VolumeIcon.icns
51 |
52 | # Directories potentially created on remote AFP share
53 | .AppleDB
54 | .AppleDesktop
55 | Network Trash Folder
56 | Temporary Items
57 | .apdisk
58 |
59 | # Windows
60 | # =========================
61 |
62 | # Windows image file caches
63 | Thumbs.db
64 | ehthumbs.db
65 |
66 | # Folder config file
67 | Desktop.ini
68 |
69 | # Recycle Bin used on file shares
70 | $RECYCLE.BIN/
71 |
72 | # Windows Installer files
73 | *.cab
74 | *.msi
75 | *.msm
76 | *.msp
77 |
78 | # Windows shortcuts
79 | *.lnk
80 |
--------------------------------------------------------------------------------
/LexAnaly/20160425220522607.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/20160425220522607.jpg
--------------------------------------------------------------------------------
/LexAnaly/Debug/词法分析.ilk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/Debug/词法分析.ilk
--------------------------------------------------------------------------------
/LexAnaly/Debug/词法分析.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/Debug/词法分析.pdb
--------------------------------------------------------------------------------
/LexAnaly/词法分析.opensdf:
--------------------------------------------------------------------------------
1 | T a c h T A C H - P C
--------------------------------------------------------------------------------
/LexAnaly/词法分析.sdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析.sdf
--------------------------------------------------------------------------------
/LexAnaly/词法分析.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "词法分析", "词法分析\词法分析.vcxproj", "{D3978F7C-3F9D-4DAD-9B80-4BBADC5A6FF4}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Release|Win32 = Release|Win32
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D3978F7C-3F9D-4DAD-9B80-4BBADC5A6FF4}.Debug|Win32.ActiveCfg = Debug|Win32
15 | {D3978F7C-3F9D-4DAD-9B80-4BBADC5A6FF4}.Debug|Win32.Build.0 = Debug|Win32
16 | {D3978F7C-3F9D-4DAD-9B80-4BBADC5A6FF4}.Release|Win32.ActiveCfg = Release|Win32
17 | {D3978F7C-3F9D-4DAD-9B80-4BBADC5A6FF4}.Release|Win32.Build.0 = Release|Win32
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/LexAnaly/词法分析.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析.v12.suo
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Base.cpp:
--------------------------------------------------------------------------------
1 | #include "Base.h"
2 |
3 | int Base::charkind(char c)
4 | {
5 | if (characters(c) == 1)
6 | {
7 | return 1;
8 | }
9 | if (numbers(c) == 1)
10 | {
11 | return 2;
12 | }
13 | if (c == '$' || c == '_')
14 | {
15 | return 3;
16 | }
17 | if (c == '\\')
18 | {
19 | return 4;
20 | }
21 | if (c == '=')
22 | {
23 | return 5;
24 | }
25 | return 0;
26 | }
27 |
28 | int Base::spaces(char c)
29 | {
30 | if ((c > 'z' || (c < 'a' && c > 'Z') || (c < 'A' && c > '9') || (c < '0')) && c != '_' && c != '$')
31 | {
32 | return 1;
33 | }
34 | return 0;
35 | }
36 | int Base::characters(char c)
37 | {
38 | if ((c <= 'z' && c >= 'a') || (c <= 'Z' && c >= 'A'))
39 | {
40 | return 1;
41 | }
42 | return 0;
43 | }
44 | int Base::keyword(char str[])
45 | {
46 | int i;
47 | for (i = 0; i < 50; i++)
48 | {
49 | if (strcmp(str, keywords[i]) == 0)
50 | {
51 | return 1;
52 | }
53 | }
54 | return 0;
55 | }
56 | int Base::signwords(char str[])
57 | {
58 | int i;
59 | if (str[0] == '$' || str[0] == '_' || characters(str[0]) == 1)
60 | {
61 | for (i = 0; str[i] != '\0'; i++)
62 | {
63 | if (spaces(str[i]) == 1)
64 | {
65 | return 0;
66 | }
67 | }
68 | return 1;
69 | }
70 | return 0;
71 | }
72 | int Base::numbers(char c)
73 | {
74 | if (c <= '9' && c >= '0')
75 | {
76 | return 1;
77 | }
78 | return 0;
79 | }
80 | int Base::integers(char str[])
81 | {
82 | int i;
83 | if (str[0] == '-' || numbers(str[0]) == 1)
84 | {
85 | for (i = 0; i < strlen(str); i++)
86 | {
87 | if (str[i] == '.')
88 | {
89 | return 0;
90 | }
91 | if ((str[i] == 'x' || str[i] == 'X') && (((str[0] == '-' || str[0] == '+') && (str[1] != '0' || i > 2)) || (str[0] != '-' && str[0] != '+' && (str[0] != '0' || i > 1))))
92 | {
93 | return 0;
94 | }
95 | if ((i < strlen(str) - 1) && numbers(str[i]) == 0 && str[i] != 'x' && str[i] != 'X')
96 | {
97 | if (strlen(str) > 2 && strnicmp("0x", str, 2) == 0 || strnicmp("-0x", str, 3) == 0)
98 | {
99 | if (str[i] >= 'A' && str[i] <= 'F')
100 | {
101 | continue;
102 | }
103 | }
104 | return 0;
105 | }
106 | if ((i == strlen(str) - 1) && numbers(str[i]) == 0 && str[i] != 'L')
107 | {
108 | if (strlen(str) > 2 && strnicmp("0x", str, 2) == 0 || strnicmp("-0x", str, 3) == 0)
109 | {
110 | if (str[i] >= 'A' && str[i] <= 'F')
111 | {
112 | continue;
113 | }
114 | }
115 | return 0;
116 | }
117 | }
118 | return 1;
119 | }
120 | return 0;
121 | }
122 | int Base::floats(char str[])
123 | {
124 | int i;
125 | int flag = 0;
126 | if (str[0] == '-' || numbers(str[0]) == 1)
127 | {
128 | for (i = 0; i < strlen(str); i++)
129 | {
130 | if (str[i] == '.')
131 | {
132 | if (flag == 0)
133 | {
134 | flag = 1;
135 | continue;
136 | }
137 | else
138 | {
139 | return 0;
140 | }
141 | }
142 | if ((str[i] == 'x' || str[i] == 'X') && (((str[0] == '-' || str[0] == '+') && (str[1] != '0' || i > 2)) || (str[0] != '-' && str[0] != '+' && (str[0] != '0' || i > 1))))
143 | {
144 | return 0;
145 | }
146 | if (numbers(str[i]) == 0 && str[i] != 'x' && str[i] != 'X')
147 | {
148 | if (strlen(str) > 2 && strnicmp("0x", str, 2) == 0 || strnicmp("-0x", str, 3) == 0)
149 | {
150 | if (str[i] >= 'A' && str[i] <= 'F')
151 | {
152 | continue;
153 | }
154 | }
155 | return 0;
156 | }
157 | }
158 | return flag;
159 | }
160 | return 0;
161 | }
162 | Base::~Base(){}
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Base.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Base.h
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/vc120.idb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Debug/vc120.idb
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/vc120.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Debug/vc120.pdb
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | f:\c++\project\词法分析\词法分析\debug\vc120.pdb
2 | f:\c++\project\词法分析\词法分析\debug\vc120.idb
3 | f:\c++\project\词法分析\词法分析\debug\lexan.obj
4 | f:\c++\project\词法分析\词法分析\debug\main.obj
5 | f:\c++\project\词法分析\词法分析\debug\词法分析.tlog\cl.command.1.tlog
6 | f:\c++\project\词法分析\词法分析\debug\词法分析.tlog\cl.read.1.tlog
7 | f:\c++\project\词法分析\词法分析\debug\词法分析.tlog\cl.write.1.tlog
8 |
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.log:
--------------------------------------------------------------------------------
1 | 生成启动时间为 2016/4/25 21:01:18。
2 | 1>项目“F:\c++\project\词法分析\词法分析\词法分析.vcxproj”在节点 2 上(Build 个目标)。
3 | 1>ClCompile:
4 | E:\安装程序\VS2013\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt Base.cpp LexAn.cpp main.cpp
5 | main.cpp
6 | 正在生成代码...
7 | 正在编译...
8 | LexAn.cpp
9 | 1>f:\c++\project\词法分析\词法分析\lexan.cpp(179): warning C4101: “k”: 未引用的局部变量
10 | 1>f:\c++\project\词法分析\词法分析\lexan.cpp(179): warning C4101: “j”: 未引用的局部变量
11 | 1>f:\c++\project\词法分析\词法分析\lexan.cpp(402): warning C4101: “i”: 未引用的局部变量
12 | 1>f:\c++\project\词法分析\词法分析\lexan.cpp(402): warning C4101: “k”: 未引用的局部变量
13 | 1>f:\c++\project\词法分析\词法分析\lexan.cpp(402): warning C4101: “j”: 未引用的局部变量
14 | Base.cpp
15 | 1>f:\c++\project\词法分析\词法分析\base.cpp(84): warning C4018: “<”: 有符号/无符号不匹配
16 | 1>f:\c++\project\词法分析\词法分析\base.cpp(94): warning C4018: “<”: 有符号/无符号不匹配
17 | 1>f:\c++\project\词法分析\词法分析\base.cpp(127): warning C4018: “<”: 有符号/无符号不匹配
18 | 正在生成代码...
19 | Link:
20 | E:\安装程序\VS2013\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"F:\c++\project\词法分析\Debug\词法分析.exe" /INCREMENTAL /NOLOGO opencv_ts300.lib opencv_world300.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"F:\c++\project\词法分析\Debug\词法分析.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"F:\c++\project\词法分析\Debug\词法分析.lib" /MACHINE:X86 Debug\Base.obj
21 | Debug\LexAn.obj
22 | Debug\main.obj
23 | 词法分析.vcxproj -> F:\c++\project\词法分析\Debug\词法分析.exe
24 | 1>已完成生成项目“F:\c++\project\词法分析\词法分析\词法分析.vcxproj”(Build 个目标)的操作。
25 |
26 | 生成成功。
27 |
28 | 已用时间 00:00:02.16
29 |
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.tlog/CL.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Debug/词法分析.tlog/CL.read.1.tlog
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.tlog/CL.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Debug/词法分析.tlog/CL.write.1.tlog
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.tlog/cl.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Debug/词法分析.tlog/cl.command.1.tlog
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.tlog/link.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Debug/词法分析.tlog/link.command.1.tlog
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.tlog/link.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Debug/词法分析.tlog/link.read.1.tlog
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.tlog/link.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/Debug/词法分析.tlog/link.write.1.tlog
--------------------------------------------------------------------------------
/LexAnaly/词法分析/Debug/词法分析.tlog/词法分析.lastbuildstate:
--------------------------------------------------------------------------------
1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
2 | Debug|Win32|F:\c++\project\词法分析\|
3 |
--------------------------------------------------------------------------------
/LexAnaly/词法分析/LexAn.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/LexAn.cpp
--------------------------------------------------------------------------------
/LexAnaly/词法分析/LexAn.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/LexAn.h
--------------------------------------------------------------------------------
/LexAnaly/词法分析/in.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/in.txt
--------------------------------------------------------------------------------
/LexAnaly/词法分析/main.cpp:
--------------------------------------------------------------------------------
1 | #include"LexAn.h"
2 |
3 | int main()
4 | {
5 | LexAn res;
6 | res.scanwords();
7 | return 0;
8 | }
--------------------------------------------------------------------------------
/LexAnaly/词法分析/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/LexAnaly/词法分析/out.txt
--------------------------------------------------------------------------------
/LexAnaly/词法分析/词法分析.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {D3978F7C-3F9D-4DAD-9B80-4BBADC5A6FF4}
15 | Win32Proj
16 | 词法分析
17 |
18 |
19 |
20 | Application
21 | true
22 | v120
23 | Unicode
24 |
25 |
26 | Application
27 | false
28 | v120
29 | true
30 | Unicode
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | true
44 |
45 |
46 | false
47 |
48 |
49 |
50 |
51 |
52 | Level3
53 | Disabled
54 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
55 | true
56 |
57 |
58 | Console
59 | true
60 |
61 |
62 |
63 |
64 | Level3
65 |
66 |
67 | MaxSpeed
68 | true
69 | true
70 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
71 | true
72 |
73 |
74 | Console
75 | true
76 | true
77 | true
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/LexAnaly/词法分析/词法分析.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 头文件
20 |
21 |
22 | 头文件
23 |
24 |
25 |
26 |
27 | 源文件
28 |
29 |
30 | 源文件
31 |
32 |
33 | 源文件
34 |
35 |
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Compiler
2 |
3 | ### 运行环境
4 | * windows 7, vs2013
5 |
6 | ### 编译原理相关代码
7 |
8 | #### C语言词法分析器
9 | * 可对C语言的词法进行分析,输出标识符,关键字,运算符,注释,空格,特殊符号等
10 | * 相对完整,适用于学习。
11 | * 具体分析详见 http://blog.csdn.net/nk_test/article/details/51245559
12 |
13 | #### LL(1)语法分析器
14 | * 求出FIRST和FOLLOW集,写出预测分析表,并给出对输入串的栈分析过程
15 | * 具体分析详见 http://blog.csdn.net/nk_test/article/details/51476663
16 |
17 |
18 |
--------------------------------------------------------------------------------
/grammar/Debug/语法.ilk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/Debug/语法.ilk
--------------------------------------------------------------------------------
/grammar/Debug/语法.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/Debug/语法.pdb
--------------------------------------------------------------------------------
/grammar/语法.sdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法.sdf
--------------------------------------------------------------------------------
/grammar/语法.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "语法", "语法\语法.vcxproj", "{3EC4A0EF-CC2A-4F7A-95ED-90EA8E9FC432}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Release|Win32 = Release|Win32
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {3EC4A0EF-CC2A-4F7A-95ED-90EA8E9FC432}.Debug|Win32.ActiveCfg = Debug|Win32
15 | {3EC4A0EF-CC2A-4F7A-95ED-90EA8E9FC432}.Debug|Win32.Build.0 = Debug|Win32
16 | {3EC4A0EF-CC2A-4F7A-95ED-90EA8E9FC432}.Release|Win32.ActiveCfg = Release|Win32
17 | {3EC4A0EF-CC2A-4F7A-95ED-90EA8E9FC432}.Release|Win32.Build.0 = Release|Win32
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/grammar/语法.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法.v12.suo
--------------------------------------------------------------------------------
/grammar/语法/Base.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Base.cpp
--------------------------------------------------------------------------------
/grammar/语法/Base.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Base.h
--------------------------------------------------------------------------------
/grammar/语法/Debug/vc120.idb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Debug/vc120.idb
--------------------------------------------------------------------------------
/grammar/语法/Debug/vc120.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Debug/vc120.pdb
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | f:\c++\project\语法\语法\debug\vc120.pdb
2 | f:\c++\project\语法\语法\debug\vc120.idb
3 | f:\c++\project\语法\语法\debug\main.obj
4 | f:\c++\project\语法\debug\语法.ilk
5 | f:\c++\project\语法\debug\语法.exe
6 | f:\c++\project\语法\debug\语法.pdb
7 | f:\c++\project\语法\语法\debug\语法.tlog\cl.command.1.tlog
8 | f:\c++\project\语法\语法\debug\语法.tlog\cl.read.1.tlog
9 | f:\c++\project\语法\语法\debug\语法.tlog\cl.write.1.tlog
10 | f:\c++\project\语法\语法\debug\语法.tlog\link.command.1.tlog
11 | f:\c++\project\语法\语法\debug\语法.tlog\link.read.1.tlog
12 | f:\c++\project\语法\语法\debug\语法.tlog\link.write.1.tlog
13 |
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.log:
--------------------------------------------------------------------------------
1 | 生成启动时间为 2016/5/22 20:22:44。
2 | 1>项目“F:\c++\project\语法\语法\语法.vcxproj”在节点 2 上(Build 个目标)。
3 | 1>ClCompile:
4 | E:\安装程序\VS2013\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt Base.cpp TableStack.cpp main.cpp
5 | Base.cpp
6 | 1>f:\c++\project\语法\语法\base.cpp(11): warning C4018: “<”: 有符号/无符号不匹配
7 | 1>f:\c++\project\语法\语法\base.cpp(20): warning C4018: “<”: 有符号/无符号不匹配
8 | 1>f:\c++\project\语法\语法\base.cpp(41): warning C4018: “<”: 有符号/无符号不匹配
9 | 1>f:\c++\project\语法\语法\base.cpp(137): warning C4018: “<”: 有符号/无符号不匹配
10 | 1>f:\c++\project\语法\语法\base.cpp(143): warning C4018: “<”: 有符号/无符号不匹配
11 | 1>f:\c++\project\语法\语法\base.cpp(147): warning C4018: “<”: 有符号/无符号不匹配
12 | 1>f:\c++\project\语法\语法\base.cpp(154): warning C4018: “<”: 有符号/无符号不匹配
13 | 1>f:\c++\project\语法\语法\base.cpp(169): warning C4018: “<”: 有符号/无符号不匹配
14 | 1>f:\c++\project\语法\语法\base.cpp(186): warning C4018: “<”: 有符号/无符号不匹配
15 | 1>f:\c++\project\语法\语法\base.cpp(191): warning C4018: “<”: 有符号/无符号不匹配
16 | 1>f:\c++\project\语法\语法\base.cpp(198): warning C4018: “<”: 有符号/无符号不匹配
17 | 1>f:\c++\project\语法\语法\base.cpp(208): warning C4018: “<”: 有符号/无符号不匹配
18 | 1>f:\c++\project\语法\语法\base.cpp(218): warning C4018: “<”: 有符号/无符号不匹配
19 | 正在生成代码...
20 | 正在编译...
21 | TableStack.cpp
22 | 1>f:\c++\project\语法\语法\tablestack.cpp(52): warning C4018: “<”: 有符号/无符号不匹配
23 | 1>f:\c++\project\语法\语法\tablestack.cpp(99): warning C4018: “<”: 有符号/无符号不匹配
24 | 1>f:\c++\project\语法\语法\tablestack.cpp(104): warning C4018: “<”: 有符号/无符号不匹配
25 | 1>f:\c++\project\语法\语法\tablestack.cpp(107): warning C4018: “<”: 有符号/无符号不匹配
26 | 正在生成代码...
27 | 正在跳过...(未检测到相关更改)
28 | main.cpp
29 | Link:
30 | E:\安装程序\VS2013\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"F:\c++\project\语法\Debug\语法.exe" /INCREMENTAL /NOLOGO opencv_ts300.lib opencv_world300.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"F:\c++\project\语法\Debug\语法.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"F:\c++\project\语法\Debug\语法.lib" /MACHINE:X86 Debug\Base.obj
31 | Debug\main.obj
32 | Debug\TableStack.obj
33 | 语法.vcxproj -> F:\c++\project\语法\Debug\语法.exe
34 | 1>已完成生成项目“F:\c++\project\语法\语法\语法.vcxproj”(Build 个目标)的操作。
35 |
36 | 生成成功。
37 |
38 | 已用时间 00:00:02.42
39 |
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.tlog/CL.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Debug/语法.tlog/CL.read.1.tlog
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.tlog/CL.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Debug/语法.tlog/CL.write.1.tlog
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.tlog/cl.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Debug/语法.tlog/cl.command.1.tlog
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.tlog/link.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Debug/语法.tlog/link.command.1.tlog
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.tlog/link.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Debug/语法.tlog/link.read.1.tlog
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.tlog/link.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/Debug/语法.tlog/link.write.1.tlog
--------------------------------------------------------------------------------
/grammar/语法/Debug/语法.tlog/语法.lastbuildstate:
--------------------------------------------------------------------------------
1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
2 | Debug|Win32|F:\c++\project\语法\|
3 |
--------------------------------------------------------------------------------
/grammar/语法/TableStack.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/TableStack.cpp
--------------------------------------------------------------------------------
/grammar/语法/TableStack.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/TableStack.h
--------------------------------------------------------------------------------
/grammar/语法/main.cpp:
--------------------------------------------------------------------------------
1 | #include "TableStack.h"
2 |
3 | int main()
4 | {
5 | TableStack res;
6 | res.getAns();
7 | return 0;
8 | }
--------------------------------------------------------------------------------
/grammar/语法/output.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tachone/Compiler/b6bc31ac2507d2b83e8315eeeaf6e78a288cd9db/grammar/语法/output.txt
--------------------------------------------------------------------------------
/grammar/语法/product.txt:
--------------------------------------------------------------------------------
1 | E->TA
2 | A->+TB
3 | A->$
4 | T->FB
5 | B->*FB
6 | B->$
7 | F->(E)
8 | F->i
--------------------------------------------------------------------------------
/grammar/语法/语法.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {3EC4A0EF-CC2A-4F7A-95ED-90EA8E9FC432}
15 | Win32Proj
16 | 语法
17 |
18 |
19 |
20 | Application
21 | true
22 | v120
23 | Unicode
24 |
25 |
26 | Application
27 | false
28 | v120
29 | true
30 | Unicode
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | true
44 |
45 |
46 | false
47 |
48 |
49 |
50 |
51 |
52 | Level3
53 | Disabled
54 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
55 | true
56 |
57 |
58 | Console
59 | true
60 |
61 |
62 |
63 |
64 | Level3
65 |
66 |
67 | MaxSpeed
68 | true
69 | true
70 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
71 | true
72 |
73 |
74 | Console
75 | true
76 | true
77 | true
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/grammar/语法/语法.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 | 源文件
23 |
24 |
25 | 源文件
26 |
27 |
28 |
29 |
30 | 头文件
31 |
32 |
33 | 头文件
34 |
35 |
36 |
--------------------------------------------------------------------------------