Skip to content

Commit

Permalink
Prepare example gate project with tranceducer pipeline
Browse files Browse the repository at this point in the history
Example project contains jape grammars and some gazetteers.
Works on #7.
  • Loading branch information
salterok committed Aug 5, 2018
1 parent 04d4ff3 commit 8f3334d
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 6 deletions.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions examples/grammar/basic.jape
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This is example file to provide syntax colorize support
* Author: Sergiy Samborskiy <[email protected]>
*
*/
Phase: Basic
Input: Lookup Token

Rule: IngredientName
Priority: 1
(
{ Lookup.majorType == "ingredient" }
): label
-->
:labe.IngredientName = { rule = "IngredientName", value = :label@string }
13 changes: 7 additions & 6 deletions examples/e1.jape → examples/grammar/e1.jape
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ Input: Lookup Token
Input: Go
// begin first rule

// Macro: sd
// (

// ): a
Macro: sd
(
{Token}
): a

Rule: Prime
Priority: 1
(
(sd)
{ Lookup.majorType == "number", Token.string == "one" } |
{ Lookup.majorType == "number", Token.string == "two" } |
{ Lookup.majorType == "number", Token.string == "tree" }
): label2
-->
-->
:label.PrimeNumber = { rule = "Number" }

Rule: NonPrime
Expand All @@ -31,4 +32,4 @@ Rule: NonPrime
): label2
-->
:label2.NotPrimeNumber = { rule = "Number", value = :label.Lookup.string },
:fourLabel.ItsFour = { rule = "Number", value = "4" }
:fourLabel.ItsFour = { rule = "Number", value = "4" }
35 changes: 35 additions & 0 deletions examples/grammar/e2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* This is example file to provide syntax colorize support
* Author: Sergiy Samborskiy <[email protected]>
*
* // Some lines here
*/
Phase: Example
Input: Lookup Token
Input: Go
// begin first rule

Macro: sd
(
{Token}
): a

Rule: Prime
Priority: 1
(
(sd)
{ Lookup.majorType == "number", Token.string == "one" } |
{ Lookup.majorType == "number", Token.string == "two" } |
{ Lookup.majorType == "number", Token.string == "tree" }
): label2
-->
:label.PrimeNumber = { rule = "Number" }

Rule: NonPrime
(
( { Lookup.majorType == "number", Token.string == "four" } ): fourLabel
| { Lookup.majorType == "number", Token.string == "five" }
): label2
-->
:label2.NotPrimeNumber = { rule = "Number", value = :label.Lookup.string },
:fourLabel.ItsFour = { rule = "Number", value = "4" }
4 changes: 4 additions & 0 deletions examples/grammar/ingredients/index.jape
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MultiPhase: Ingredients

Phases:
ingredients1
18 changes: 18 additions & 0 deletions examples/grammar/ingredients/ingredients1.jape
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

Phase: BasicIngredients
Input: Quantity IngredientName

Rule: Ingredient1
(
({ Quantity }): qty
({ IngredientName }): ingredient
): label
-->
:labe.Ingredient = { rule = "Ingredient", qty = :qty.Quantity.value, name = :ingredient.IngredientName.value }

Rule: Ingredient2
(
({ IngredientName }): ingredient
): label
-->
:labe.Ingredient = { rule = "Ingredient", qty = "", name = :ingredient.IngredientName.value }
9 changes: 9 additions & 0 deletions examples/grammar/main.jape
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MultiPhase: Main

Phases:
basic

quantity/index
ingredients/index

result
4 changes: 4 additions & 0 deletions examples/grammar/quantity/index.jape
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MultiPhase: Quantity

Phases:
quantity1
13 changes: 13 additions & 0 deletions examples/grammar/quantity/quantity1.jape
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Phase: BasicQuantity
Input: Lookup Token

Rule: Quantity1
Priority: 1
(
({ Token.type == "number" }): value
({ Lookup.majorType == "measure_unit" }): unit
): label
-->
:labe.Quantity = { rule = "Quantity", value = :value@string, unit = :unit@string }

9 changes: 9 additions & 0 deletions examples/grammar/result.jape
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Phase: ResultMatcher
Input: Ingredient

Rule: Result
(
({ Ingredient }): ingredient
): label
-->
:labe.Result = { rule = "Ingredient", qty = :ingredient.Ingredient.qty, name = :ingredient.IngredientName.value }

0 comments on commit 8f3334d

Please sign in to comment.