Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Knetic committed Jun 18, 2015
1 parent a1688ed commit 5e168e9
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 100 deletions.
6 changes: 3 additions & 3 deletions parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func readToken(stream *lexerStream, state lexerState) (ExpressionToken, error, b
tokenValue, completed = readUntilFalse(stream, true, false, isNotClosingBracket)
kind = VARIABLE

if(!completed) {
if !completed {
return ExpressionToken{}, errors.New("Unclosed parameter bracket"), false
}

Expand Down Expand Up @@ -138,7 +138,7 @@ func readToken(stream *lexerStream, state lexerState) (ExpressionToken, error, b
if !isNotQuote(character) {
tokenValue, completed = readUntilFalse(stream, true, false, isNotQuote)

if(!completed) {
if !completed {
return ExpressionToken{}, errors.New("Unclosed string literal"), false
}

Expand Down Expand Up @@ -239,7 +239,7 @@ func readUntilFalse(stream *lexerStream, includeWhitespace bool, breakWhitespace
character = stream.readCharacter()

// Use backslashes to escape anything
if(character == '\\') {
if character == '\\' {

character = stream.readCharacter()
tokenBuffer.WriteString(string(character))
Expand Down
4 changes: 2 additions & 2 deletions parsingFailure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const (
UNEXPECTED_END string = "Unexpected end of expression"
INVALID_TOKEN_TRANSITION = "Cannot transition token types"
INVALID_TOKEN_KIND = "Invalid token"
UNCLOSED_QUOTES = "Unclosed string literal"
UNCLOSED_BRACKETS = "Unclosed parameter bracket"
UNCLOSED_QUOTES = "Unclosed string literal"
UNCLOSED_BRACKETS = "Unclosed parameter bracket"
)

/*
Expand Down
190 changes: 95 additions & 95 deletions parsing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,34 +456,34 @@ func TestPrefixParsing(test *testing.T) {

testCases := []TokenParsingTest{

TokenParsingTest {
TokenParsingTest{

Name: "Sign prefix",
Name: "Sign prefix",
Input: "-1",
Expected: []ExpressionToken {
ExpressionToken {
Kind: PREFIX,
Value: "-",
},
ExpressionToken {
Kind: NUMERIC,
Value: 1.0,
},
Expected: []ExpressionToken{
ExpressionToken{
Kind: PREFIX,
Value: "-",
},
ExpressionToken{
Kind: NUMERIC,
Value: 1.0,
},
},
},
TokenParsingTest {
TokenParsingTest{

Name: "Sign prefix on variable",
Name: "Sign prefix on variable",
Input: "-foo",
Expected: []ExpressionToken {
ExpressionToken {
Kind: PREFIX,
Value: "-",
},
ExpressionToken {
Kind: VARIABLE,
Value: "foo",
},
Expected: []ExpressionToken{
ExpressionToken{
Kind: PREFIX,
Value: "-",
},
ExpressionToken{
Kind: VARIABLE,
Value: "foo",
},
},
},
TokenParsingTest{
Expand Down Expand Up @@ -524,82 +524,82 @@ func TestPrefixParsing(test *testing.T) {

func TestEscapedParameters(test *testing.T) {

testCases := []TokenParsingTest{

TokenParsingTest {

Name: "Single escaped parameter",
Input: "[foo]",
Expected: []ExpressionToken {
ExpressionToken {
Kind: VARIABLE,
Value: "foo",
},
},
},
TokenParsingTest {

Name: "Single escaped parameter with whitespace",
Input: "[foo bar]",
Expected: []ExpressionToken {
ExpressionToken {
Kind: VARIABLE,
Value: "foo bar",
},
},
},
TokenParsingTest {

Name: "Single escaped parameter with escaped closing bracket",
Input: "[foo[bar\\]]",
Expected: []ExpressionToken {
ExpressionToken {
Kind: VARIABLE,
Value: "foo[bar]",
},
},
},
TokenParsingTest {

Name: "Escaped parameters and unescaped parameters",
Input: "[foo] > bar",
Expected: []ExpressionToken {
ExpressionToken {
Kind: VARIABLE,
Value: "foo",
},
ExpressionToken{
Kind: COMPARATOR,
Value: ">",
},
ExpressionToken{
Kind: VARIABLE,
Value: "bar",
},
},
},
TokenParsingTest {

Name: "Unescaped parameter with space",
Input: "foo\\ bar > bar",
Expected: []ExpressionToken {
ExpressionToken {
Kind: VARIABLE,
Value: "foo bar",
},
ExpressionToken{
Kind: COMPARATOR,
Value: ">",
},
ExpressionToken{
Kind: VARIABLE,
Value: "bar",
},
testCases := []TokenParsingTest{

TokenParsingTest{

Name: "Single escaped parameter",
Input: "[foo]",
Expected: []ExpressionToken{
ExpressionToken{
Kind: VARIABLE,
Value: "foo",
},
},
}
},
TokenParsingTest{

Name: "Single escaped parameter with whitespace",
Input: "[foo bar]",
Expected: []ExpressionToken{
ExpressionToken{
Kind: VARIABLE,
Value: "foo bar",
},
},
},
TokenParsingTest{

runTokenParsingTest(testCases, test)
Name: "Single escaped parameter with escaped closing bracket",
Input: "[foo[bar\\]]",
Expected: []ExpressionToken{
ExpressionToken{
Kind: VARIABLE,
Value: "foo[bar]",
},
},
},
TokenParsingTest{

Name: "Escaped parameters and unescaped parameters",
Input: "[foo] > bar",
Expected: []ExpressionToken{
ExpressionToken{
Kind: VARIABLE,
Value: "foo",
},
ExpressionToken{
Kind: COMPARATOR,
Value: ">",
},
ExpressionToken{
Kind: VARIABLE,
Value: "bar",
},
},
},
TokenParsingTest{

Name: "Unescaped parameter with space",
Input: "foo\\ bar > bar",
Expected: []ExpressionToken{
ExpressionToken{
Kind: VARIABLE,
Value: "foo bar",
},
ExpressionToken{
Kind: COMPARATOR,
Value: ">",
},
ExpressionToken{
Kind: VARIABLE,
Value: "bar",
},
},
},
}

runTokenParsingTest(testCases, test)
}

func combineWhitespaceExpressions(testCases []TokenParsingTest) []TokenParsingTest {
Expand Down

0 comments on commit 5e168e9

Please sign in to comment.