Skip to content

Commit

Permalink
finish line pragma generation, extend configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparnagy committed Nov 25, 2009
1 parent 3e3515b commit f88203b
Show file tree
Hide file tree
Showing 36 changed files with 1,519 additions and 977 deletions.
9 changes: 7 additions & 2 deletions Parser/Configuration/GeneratorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace TechTalk.SpecFlow.Parser.Configuration
public class GeneratorConfiguration
{
//language settings
public CultureInfo FeatureLanguage { get; set; } //TODO: use
public CultureInfo ToolLanguage { get; set; } //TODO: use
public CultureInfo FeatureLanguage { get; set; }
public CultureInfo ToolLanguage { get; set; }

//unit test framework settings
public Type GeneratorUnitTestProviderType { get; set; }
Expand Down Expand Up @@ -51,6 +51,11 @@ internal void UpdateFromConfigFile(ConfigurationSectionHandler configSection)

//TODO: config.CheckUnitTestConfig();
}

if (configSection.Generator != null)
{
AllowDebugGeneratedFiles = configSection.Generator.AllowDebugGeneratedFiles;
}
}

private static Type GetTypeConfig(string typeName)
Expand Down
12 changes: 12 additions & 0 deletions Parser/Grammar/ErrorReporting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Linq;
using System.Text;
using TechTalk.SpecFlow.Parser.SyntaxElements;

namespace TechTalk.SpecFlow.Parser.Grammar
{
Expand All @@ -21,5 +22,16 @@ public override void EmitErrorMessage(string msg)
Debug.WriteLine(msg);
ParserErrors.Add(msg);
}

protected string GetFilePosition()
{
var node = input.LT(1);
return string.Format("{0}:{1}", node.Line, node.CharPositionInLine + 1);
}

public void Hehe()
{
Debug.WriteLine("hehe");
}
}
}
1,200 changes: 651 additions & 549 deletions Parser/Grammar/SpecFlowLangParser.cs

Large diffs are not rendered by default.

111 changes: 91 additions & 20 deletions Parser/Grammar/SpecFlowLangParser.g
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ tokens {
BODY;
ROW;
CELL;
FILEPOSITION;
}

//@lexer::namespace { TechTalk.SpecFlow.Parser.Grammar }
Expand Down Expand Up @@ -72,10 +73,17 @@ descriptionLine
;

background
: WS? T_BACKGROUND
@init {
string fp_ = null;
}
: WS?
{
fp_ = GetFilePosition();
}
T_BACKGROUND
(WS title)?
newlineWithSpaces givens
-> ^(BACKGROUND title? givens)
-> ^(BACKGROUND title? givens FILEPOSITION[fp_])
;

scenarioKind
Expand All @@ -84,19 +92,33 @@ scenarioKind
;

scenario
: tags? WS? T_SCENARIO WS?
@init {
string fp_ = null;
}
: tags? WS?
{
fp_ = GetFilePosition();
}
T_SCENARIO WS?
title newlineWithSpaces
steps
-> ^(SCENARIO tags? title steps)
-> ^(SCENARIO tags? title steps FILEPOSITION[fp_])
;

scenarioOutline
@init {
string fp_ = null;
}
:
tags? WS? T_SCENARIO_OUTLINE WS?
tags? WS?
{
fp_ = GetFilePosition();
}
T_SCENARIO_OUTLINE WS?
title newlineWithSpaces
steps
examples
-> ^(SCENARIOOUTLINE tags? title steps examples)
-> ^(SCENARIOOUTLINE tags? title steps examples FILEPOSITION[fp_])
;

examples
Expand Down Expand Up @@ -126,30 +148,65 @@ nextStep
;

firstAnd
: WS? T_AND WS sentenceEnd
-> ^(AND sentenceEnd)
@init {
string fp_ = null;
}
: WS?
{
fp_ = GetFilePosition();
}
T_AND WS sentenceEnd
-> ^(AND sentenceEnd FILEPOSITION[fp_])
;

firstBut
: WS? T_BUT WS sentenceEnd
-> ^(BUT sentenceEnd)
@init {
string fp_ = null;
}
: WS?
{
fp_ = GetFilePosition();
}
T_BUT WS sentenceEnd
-> ^(BUT sentenceEnd FILEPOSITION[fp_])
;

givens
: firstGiven nextStep*
-> ^(STEPS firstGiven nextStep*)
;
firstGiven
: WS? T_GIVEN WS sentenceEnd
-> ^(GIVEN sentenceEnd)
@init {
string fp_ = null;
}
: WS?
{
fp_ = GetFilePosition();
}
T_GIVEN WS sentenceEnd
-> ^(GIVEN sentenceEnd FILEPOSITION[fp_])
;
firstWhen
: WS? T_WHEN WS sentenceEnd
-> ^(WHEN sentenceEnd)
@init {
string fp_ = null;
}
: WS?
{
fp_ = GetFilePosition();
}
T_WHEN WS sentenceEnd
-> ^(WHEN sentenceEnd FILEPOSITION[fp_])
;
firstThen
: WS? T_THEN WS sentenceEnd
-> ^(THEN sentenceEnd)
@init {
string fp_ = null;
}
: WS?
{
fp_ = GetFilePosition();
}
T_THEN WS sentenceEnd
-> ^(THEN sentenceEnd FILEPOSITION[fp_])
;

sentenceEnd
Expand Down Expand Up @@ -179,13 +236,27 @@ table
;

tableRow
: WS? CELLSEP tableCell+ WS? newlineWithSpaces
-> ^(ROW tableCell+)
@init {
string fp_ = null;
}
: WS?
{
fp_ = GetFilePosition();
}
CELLSEP tableCell+ WS? newlineWithSpaces
-> ^(ROW tableCell+ FILEPOSITION[fp_])
;

tableCell
: WS? text WS? CELLSEP
-> ^(CELL text)
@init {
string fp_ = null;
}
: WS?
{
fp_ = GetFilePosition();
}
text WS? CELLSEP
-> ^(CELL text FILEPOSITION[fp_])
;

descriptionLineText
Expand Down
Loading

0 comments on commit f88203b

Please sign in to comment.