<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <EnableDefaultAntlrItems Condition="'$(EnableDefaultAntlrItems)' == ''">True</EnableDefaultAntlrItems>
  </PropertyGroup>

  <ItemGroup Condition="'$(EnableDefaultItems)' == 'True' AND '$(EnableDefaultNoneItems)' == 'True'">
    <None Remove="**/*.g" Condition="'$(EnableDefaultAntlrItems)' == 'True'" />
    <None Remove="**/*.g3" Condition="'$(EnableDefaultAntlrItems)' == 'True'" />
    <None Remove="**/*.tokens" Condition="'$(EnableDefaultAntlrItems)' == 'True'" />
  </ItemGroup>

  <!-- Modify the CustomToolNamespace based on the directory location of the grammar -->
  <ItemGroup>
    <Antlr3 Update="@(Antlr3)" DefaultCustomToolNamespace="$([MSBuild]::ValueOrDefault(%(RelativeDir), '').Replace('\', '.').Replace('/', '.').TrimEnd('.'))" />
    <Antlr3 Update="@(Antlr3)" Condition="'$(RootNamespace)' != ''" DefaultCustomToolNamespace="$([MSBuild]::ValueOrDefault('$(RootNamespace).%(DefaultCustomToolNamespace)', '').TrimEnd('.'))" />
    <Antlr3 Update="@(Antlr3)" CustomToolNamespace="$([MSBuild]::ValueOrDefault(%(CustomToolNamespace), %(DefaultCustomToolNamespace)))" />
  </ItemGroup>

</Project>
