添加项目文件。
This commit is contained in:
parent
1cedd76eac
commit
235500f8ce
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.12.35527.113 d17.12
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompilerDesignIFlr1", "CompilerDesignIFlr1\CompilerDesignIFlr1.csproj", "{A7C303EC-99CC-4B0B-93B1-1EAD185DF63B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A7C303EC-99CC-4B0B-93B1-1EAD185DF63B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A7C303EC-99CC-4B0B-93B1-1EAD185DF63B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A7C303EC-99CC-4B0B-93B1-1EAD185DF63B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A7C303EC-99CC-4B0B-93B1-1EAD185DF63B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompilerDesignIFlr1
|
||||
{
|
||||
internal class GrammarReader
|
||||
{
|
||||
public GrammarReader(Uri grammarFilePath)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompilerDesignIFlr1
|
||||
{
|
||||
internal class LR1Closure
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompilerDesignIFlr1
|
||||
{
|
||||
internal class LR1Unit
|
||||
{
|
||||
public LR1Unit() { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompilerDesignIflr1
|
||||
{
|
||||
internal class LexicalAnalysis
|
||||
{
|
||||
string Text { get; set; } = "";
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
Console.WriteLine("Hello, World!");
|
|
@ -0,0 +1,93 @@
|
|||
@top Program {
|
||||
StatementList
|
||||
}
|
||||
|
||||
StatementList {
|
||||
Statement*
|
||||
}
|
||||
|
||||
@skip { Whitespace }
|
||||
|
||||
IfStatement {
|
||||
If LParen ConditionalExpression RParen PartIfStatement Else Statement | If LParen ConditionalExpression RParen Statement
|
||||
}
|
||||
|
||||
PartIfStatement {
|
||||
If LParen ConditionalExpression RParen PartIfStatement Else PartIfStatement | NoIfStatement
|
||||
}
|
||||
|
||||
ConditionalExpression {
|
||||
Expression Operator Expression | Expression
|
||||
}
|
||||
|
||||
Expression {
|
||||
Term (AddLike Term)*
|
||||
}
|
||||
|
||||
Statement {
|
||||
IfStatement | NoIfStatement
|
||||
}
|
||||
|
||||
NoIfStatement {
|
||||
AssignmentStatement Semicolon | VariableDefinition Semicolon | LBrace Statement* RBrace | ConstantDefinition Semicolon
|
||||
}
|
||||
|
||||
AssignmentStatement {
|
||||
Identifier Equal Expression
|
||||
}
|
||||
|
||||
Term {
|
||||
Factor (MultiplyLike Factor)*
|
||||
}
|
||||
|
||||
VariableDefinition {
|
||||
Type (Identifier | Identifier Equal Expression)+
|
||||
}
|
||||
|
||||
ConstantDefinition {
|
||||
Const VariableDefinition
|
||||
}
|
||||
|
||||
Type {
|
||||
Int | Char
|
||||
}
|
||||
|
||||
Factor {
|
||||
Identifier | Number | Character | LParen Expression RParen
|
||||
}
|
||||
|
||||
AddLike {
|
||||
Plus | Minus
|
||||
}
|
||||
|
||||
MultiplyLike {
|
||||
Multiply | Divide | Modulo
|
||||
}
|
||||
|
||||
Number {
|
||||
UnsignedNumber | Minus UnsignedNumber | Plus UnsignedNumber
|
||||
}
|
||||
@tokens {
|
||||
If { "!if" }
|
||||
Else { "!else" }
|
||||
Int {"!int"}
|
||||
Char {"!char"}
|
||||
Const { "!const" }
|
||||
Plus { "+" }
|
||||
Minus { "-" }
|
||||
Multiply { "*" }
|
||||
Modulo { "%" }
|
||||
Divide { "/" }
|
||||
LParen { "(" }
|
||||
RParen { ")" }
|
||||
LBrace { "{" }
|
||||
RBrace { "}" }
|
||||
Semicolon { ";" }
|
||||
Identifier { $[a-zA-Z_]$[a-zA-Z0-9_]* }
|
||||
UnsignedNumber { $[0-9]+ }
|
||||
String { "\"" $[\x00-\x7F]* "\"" }
|
||||
Character { "'" $[\x00-\x7F] "'" }
|
||||
Operator { "==" | "!=" | "<=" | ">=" | "<" | ">" }
|
||||
Equal { "=" }
|
||||
Whitespace { $[\t\n\r]+ }
|
||||
}
|
Loading…
Reference in New Issue