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.

Unexpected token with moo lexer

See original GitHub issue

I would like to use the moo lexer together with nearley, but I keep getting the error Unexpected column token for various reasons for very simple strings, such as "description contains abc".

I’m trying to implement some kind of searching language where you can do things like username = xyz and ("full name" contains " A. " or "full name" contains " B. ").

Before moving to the moo lexer everything was working kind of nicely. Perhaps by having a look at the grammar someone knows what I am doing wrong? That would really help me 😃

@preprocessor typescript

@{%
const moo = require('moo');

const lexer = moo.compile({
    ws: {match: /\s+/, lineBreaks: true},
    connector: /and|or/, // Any difference with `connector: ['and', 'or']`?
    leftParen: '(',
    rightParen: ')',
    field: /(?:[A-Za-z][A-Za-z0-9_]*)|(?:"[A-Za-z][A-Za-z0-9_ ]*?")/,
    operator: /contains|not contains|=|<|>/,
    value: /(?:[^\s()"]+)|(?:"[^\s()"]*?")/
});
%}

@lexer lexer

bexp -> bexp %ws %connector %ws bexp
bexp -> %leftParen _ bexp _ %rightParen
bexp -> pred

pred -> %field %ws %operator %ws %value

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
tjvrcommented, Feb 15, 2018

Hooray! 🎉

I’m glad we got it sorted 😄

I agree there are a few things we could improve in the documentation; feel free to raise issues or PR these if you have time 😃

0reactions
inad9300commented, Feb 14, 2018

No need to look into the code, it is working with 0.4.3 without problems.

Thanks a lot for all your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected WS token - javascript - Stack Overflow
I am using nearley.js and moo.
Read more >
#mootokens - YouTube
In this video I'll introduce how to use the Moo.js lexer/tokenizer with ... TOKEN CRYPTO COIN ALTCOIN HOW TO BUY NFT NFTS BSC...
Read more >
moo examples - CodeSandbox
Learn how to use moo by viewing and forking moo example apps on CodeSandbox.
Read more >
Lexer.Next, shared-source-cli-2.0 C# (CSharp) Code Examples ...
These are the top rated real world C# (CSharp) examples of Lexer. ... AreEqual("String not closed - Unexpected end of file", lexer.Errors[0].Message); }....
Read more >
Introduction to Compilers and Language Design Copyright ...
sired definition of each token, which can result in unexpected behavior on ... moo*. 1 mo,moo,mooo,... l. (moo)*. 1 ǫ,moo,moomoo,moomoomoo,... l a(b|a)*a.
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