question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

caseInsensitive error: expected a Terminal (e.g. "abc")

See original GitHub issue

ohm-js version: 0.14.0

i got an error after moving my working grammar from the online ohm-editor to my node program. when running the following in node:

// test.js
const ohm = require('ohm-js')

ohm.grammar(`
Test {
  Match = i<"foo">
  i<x> = caseInsensitive<x>
}
`)

it fails with the error, complaining about the rule i<x>, apparently:

~/Programming/sceditor $ node test.js
/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/errors.js:233
      throw errors[0];
      ^

Error: Incorrect argument type: expected a Terminal (e.g. "abc")
    at createError (/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/errors.js:20:9)
    at Object.incorrectArgumentType (/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/errors.js:143:10)
    at Apply.pexprs.Apply._assertAllApplicationsAreValid (/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/pexprs-assertAllApplicationsAreValid.js:98:20)
    at Apply.pexprs.PExpr.assertAllApplicationsAreValid (/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/pexprs-assertAllApplicationsAreValid.js:24:8)
    at /Users/n642275/Programming/sceditor/node_modules/ohm-js/src/GrammarDecl.js:115:12
    at Array.forEach (<anonymous>)
    at GrammarDecl.build (/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/GrammarDecl.js:107:30)
    at Semantics.Wrapper.Grammar (/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/main.js:85:20)
    at Operation.doAction (/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/Semantics.js:659:16)
    at Operation.execute (/Users/n642275/Programming/sceditor/node_modules/ohm-js/src/Semantics.js:627:18)

replacing the application of i<"foo"> with righthand caseInsensitive<"foo"> is a workaround the issue.

it works in the online editor, which doesn’t complain about this. might be that the hosted ohm-js script version is newer/older than the npm package?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
alexwarthcommented, Nov 8, 2019

Hi htor,

The issue is that the caseInsensitive rule is not actually a rule. In fact, if you look at the code you’ll see that we called it “case insensitive terminal”. It exists to give the author of a grammar a way to express that a terminal is not case sensitive (which is what you get by default in Ohm). At the time, @pdubroy and I considered just adding a different syntax for case-insensitive terminals, but in the end we decided on this pseudo-rule because it is more explicit. The down side is that the fact that it’s not a full-fledged rule is also confusing, as you’ve discovered. Sorry about that!

And to address ashnur’s comment: yes, it’s been some time since we last made any changes to the code, or published a new version of the npm. But this project is certainly not dead! I for one am still using Ohm in a bunch of different projects.

Best, Alex

0reactions
ashnurcommented, Nov 8, 2019

OTOH. you can install the github version from npm with just npm i harc/ohm I think.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GitHub Branches: Case-Sensitivity Issue? - Stack Overflow
Notice in this example that the remote branch is named Abc but the local branch is abc (lowercase). To solve your issue I...
Read more >
Why is the terminal case-sensitive? - Unix Stack Exchange
A case sensitive namespace is not just twice as big as an insensitive one -- the difference grows exponentially with word length. Eg,...
Read more >
Case Insensitive Choice Type · Issue #569 · pallets/click · GitHub
I've been converting a sprawling argparse CLI over to Click (and enjoying the improvements, btw), and I've run into a bit of an...
Read more >
Weekend Scripter: Unexpected Case Sensitivity in PowerShell
The PowerShell RegEx native methods (eg -match, Select-String, etc) are case insensitive, case-sensitive methods do exist (ie -cmatch). This is ...
Read more >
The Case For Case Insensitivity - Coding Horror
This is a problem with scripting languages in general. Case sensitivity just happens to be one of the many ways that programmers can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found