Skip to content

Commit

Permalink
Add a non-working parser
Browse files Browse the repository at this point in the history
  • Loading branch information
oboroc committed Jun 29, 2019
1 parent 91f0fd6 commit 30473e0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 6,4 @@ Release/
# custom
*.flex.*
lex.backup
*.tab.c
18 changes: 18 additions & 0 deletions build/vs2019/crass/crass.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 135,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\crass.c" />
<ClCompile Include="parser.tab.c" />
<ClCompile Include="scanner.flex.c" />
</ItemGroup>
<ItemGroup>
Expand All @@ -160,6 161,23 @@
<ItemGroup>
<Text Include="..\..\..\examples\test.txt" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\..\src\parser.y">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">win_bison.exe $(ProjectDir)..\..\..\src\parser.y</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Performing win_bison.exe on parser.y</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">win_bison.exe $(ProjectDir)..\..\..\src\parser.y</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Performing win_bison.exe on parser.y</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">win_bison.exe $(ProjectDir)..\..\..\src\parser.y</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Performing win_bison.exe on parser.y</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">win_bison.exe $(ProjectDir)..\..\..\src\parser.y</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Performing win_bison.exe on parser.y</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">parser.tab.c</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">parser.tab.c</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">parser.tab.c</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">parser.tab.c</Outputs>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
8 changes: 8 additions & 0 deletions build/vs2019/crass/crass.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 21,9 @@
<ClCompile Include="scanner.flex.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="parser.tab.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="scanner.flex.h">
Expand All @@ -35,4 38,9 @@
<ItemGroup>
<Text Include="..\..\..\examples\test.txt" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\src\parser.y">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
</Project>
30 changes: 30 additions & 0 deletions src/parser.y
Original file line number Diff line number Diff line change
@@ -0,0 1,30 @@

%token TYPE DOTDOT ID

%left ' ' '-'
%left '*' '/'


%%
type_decl: TYPE ID '=' type ';' ;

type:
'(' id_list ')'
| expr DOTDOT expr
;


id_list:
ID
| id_list ',' ID
;


expr:
'(' expr ')'
| expr ' ' expr
| expr '-' expr
| expr '*' expr
| expr '/' expr
| ID
;

0 comments on commit 30473e0

Please sign in to comment.