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

Commit

Permalink
Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaasonen committed Sep 6, 2018
1 parent 1fec7f0 commit f112879
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/aslGrammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ function mapFields (evaluetedFields, properties) {
return _(properties).zip(fieldValues).fromPairs().value()
}

function isIgnorable (value) {
const ignore = /Attinger|\.\.\.|^\?$|\/.+\/|[A-Z]|^[0-9]/
const ignoreMark = /⁻|⁺/
return ignore.test(value.value) || ignoreMark.test(value.mark)
}

const aslOhm = fs.readFileSync('lib/asl.ohm')
const aslGrammar = ohm.grammar(aslOhm)
const aslSemantics = aslGrammar.createSemantics().addOperation('eval', {
Expand Down Expand Up @@ -50,18 +56,17 @@ const aslSemantics = aslGrammar.createSemantics().addOperation('eval', {
return {fake: true}
},
Value: function (tag, language, key, proofExample, fields) {
const ignore = /Attinger|\.\.\.|^\?$|\/.+\/|[A-Z]|^[0-9]/
const ignoreMark = /⁻|⁺/
const evaluatedLanguage = _.head(language.eval())
const evaluatedProofExample = _.head(proofExample.eval())
const evaluetedFields = fields.eval()
const properties = ['notes', 'internalNotes']
const value = key.eval()
return ignore.test(value.value) || ignoreMark.test(value.mark)

return isIgnorable(value)
? {}
: {
values: {
...(_.omit(key.eval(), 'mark')),
...(_.omit(value, 'mark')),
questionable: tag.sourceString.endsWith('?'),
deprecated: tag.sourceString.endsWith('-'),
...(evaluatedLanguage ? {languageRestriction: evaluatedLanguage} : {}),
Expand Down

0 comments on commit f112879

Please sign in to comment.