Unexpected token with moo lexer
See original GitHub issueI 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:
- Created 6 years ago
- Comments:16
Top Results From Across the Web
#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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 😃
No need to look into the code, it is working with 0.4.3 without problems.
Thanks a lot for all your help!