Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Refactor grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaasonen committed Sep 6, 2018
1 parent cbd154d commit 1fec7f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/asl.ohm
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ Asl {
FreeTextField<tag> = tag freetext
freetext = (~("\n" | "\r") any)+

Value = ("@v?" | "@v-"| "@v") language? value ("[" Instance "]")? ScopedField*
Value = ("@v?" | "@v-"| "@v") language? value ProofExample? ScopedField*
language = "%" lower+
value = badValue | reading
ProofExample = "[" Instance "]"
badValue = reading ("-"? reading)+
reading = (~(space | "₀".."₉" | "ₓ" | "-") any)+ subIndex? ("⁺" | "⁻" | "?")? modifier*
modifier = "@" (lower | digit)+
Expand Down
5 changes: 4 additions & 1 deletion lib/aslGrammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const aslSemantics = aslGrammar.createSemantics().addOperation('eval', {
Fake: function (tag, one) {
return {fake: true}
},
Value: function (tag, language, key, openingBracket, proofExample, closingBracket, fields) {
Value: function (tag, language, key, proofExample, fields) {
const ignore = /Attinger|\.\.\.|^\?$|\/.+\/|[A-Z]|^[0-9]/
const ignoreMark = /⁻|⁺/
const evaluatedLanguage = _.head(language.eval())
Expand Down Expand Up @@ -80,6 +80,9 @@ const aslSemantics = aslGrammar.createSemantics().addOperation('eval', {
mark: mark.sourceString
}
},
ProofExample: function (openingBracket, proofExample, closingBracket) {
return proofExample.eval()
},
badValue: function (head, dash, tail) {
return {
value: '?',
Expand Down

0 comments on commit 1fec7f0

Please sign in to comment.