Skip to content

Commit

Permalink
fix parser glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
edadma committed May 24, 2018
1 parent e012d05 commit 897d8ce
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Liquescent
[![Build Status](https://www.travis-ci.org/edadma/liquescent.svg?branch=master)](https://www.travis-ci.org/edadma/liquescent)
[![Coverage Status](https://coveralls.io/repos/github/edadma/liquescent/badge.svg?branch=master)](https://coveralls.io/github/edadma/liquescent?branch=master)
[![License](https://img.shields.io/badge/license-ISC-blue.svg)](https://github.com/edadma/liquescent/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/latest_release-v0.2.2-orange.svg)](https://github.com/edadma/liquescent/releases/tag/v0.2.2)
[![Version](https://img.shields.io/badge/latest_release-v0.2.3-orange.svg)](https://github.com/edadma/liquescent/releases/tag/v0.2.3)

*Liquescent* is an implementation of the [Liquid](https://shopify.github.io/liquid/) templating language for the [Scala](http://scala-lang.org) programming language.

Expand Down Expand Up @@ -96,7 +96,7 @@ This program prints
This next example shows how to use *Liquescent* as an executable on the command line.

```bash
echo "{{ v | join: \", \" }}" | java -jar liquescent-0.2.2.jar -j "{v: [\"one\", \"two\", \"three\"]}" --
echo "{{ v | join: \", \" }}" | java -jar liquescent-0.2.3.jar -j "{v: [\"one\", \"two\", \"three\"]}" --
```

The above command prints
Expand All @@ -118,7 +118,7 @@ Use the following definition to use Liquescent in your Maven project:
<dependency>
<groupId>xyz.hyperreal</groupId>
<artifactId>liquescent</artifactId>
<version>0.2.2</version>
<version>0.2.3</version>
</dependency>
```

Expand All @@ -127,7 +127,7 @@ Add the following to your `build.sbt` file to use Liquescent in your SBT project
```sbt
resolvers += "Hyperreal Repository" at "https://dl.bintray.com/edadma/maven"

libraryDependencies += "xyz.hyperreal" %% "liquescent" % "0.2.2"
libraryDependencies += "xyz.hyperreal" %% "liquescent" % "0.2.3"
```

Building
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "liquescent"

version := "0.2.2"
version := "0.2.3"

scalaVersion := "2.12.6"

Expand Down
7 changes: 6 additions & 1 deletion src/main/scala/LiquescentParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ class LiquescentParser extends RegexParsers with PackratParsers {

lazy val source: PackratParser[StatementAST] = block ~ opt(endTextOutput) ^^ {
case b ~ None => b
case BlockStatementAST( Nil, _, _ ) ~ Some( t ) => t
case BlockStatementAST( b, _, _ ) ~ Some( t ) => BlockStatementAST( b :+ t, false, false )
case s ~ Some( t ) => BlockStatementAST( List(s, t), false, false )
}

lazy val block: PackratParser[StatementAST] = rep(statement) ^^ (l => if (l.length == 1) l.head else BlockStatementAST( l, l.head.ls, l.last.rs ))
lazy val block: PackratParser[StatementAST] = rep(statement) ^^ {
case Nil => BlockStatementAST( Nil, false, false )
case List( s ) => s
case l => BlockStatementAST( l, l.head.ls, l.last.rs )
}

lazy val statement: PackratParser[StatementAST] = tag | objectOutput | textOutput

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ object Main extends App {

def usage {
"""
|liquescent v0.2.2
|liquescent v0.2.3
|
|Usage: java -jar liquescent-0.2.2.jar <options> <liquid template>
|Usage: java -jar liquescent-0.2.3.jar <options> <liquid template>
|
|Options: --help display this help and exit
| -s <name> <string> assign <string> to variable <name>
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Main extends Testing with App {
val res =
test(
"""
|{% include 'asdf' %}
|
""".stripMargin, false, "list" -> List( 3, 4, 5 )
)

Expand Down

0 comments on commit 897d8ce

Please sign in to comment.