8000 Getting odd error message from ANTLR lab · Issue #96 · antlr/antlr4-lab · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Getting odd error message from ANTLR lab #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
QGhd opened this issue Apr 19, 2025 · 0 comments
Open

Getting odd error message from ANTLR lab #96

QGhd opened this issue Apr 19, 2025 · 0 comments

Comments

@QGhd
Copy link
QGhd commented Apr 19, 2025

Hi ANTLR experts,

I have entered this grammar to the lab:

// ANTLR Grammar for identifiers decorated by zero or one prefix (separated by underscore) and zero, one or more suffixes (also separated by underscores).
grammar PropNaming;

options { caseInsensitive = false; }

propnames
  : propname (NEWLINE+ propname)* NEWLINE* EOF
  ;

propname
  : mathprefix?
    baseprop
    contsuffix?
    intenssuffix?
  ;

mathprefix 
  : PREFIXln
  | PREFIXlog
  ;

baseprop 
  : TOKENA
  | TOKENm
  ;

contsuffix
  : SUFFIXig
  | SUFFIXres
  ;

intenssuffix
  : SUFFIXV
  | SUFFIXm
  ;

PREFIXln  : FRAGMENTln US ;
PREFIXlog : FRAGMENTlog US ;
TOKENA   : FRAGMENTA ;
TOKENm   : FRAGMENTm ;
SUFFIXig  : US FRAGMENTig ;
SUFFIXres : US FRAGMENTres ;
SUFFIXV   : US FRAGMENTV ;
SUFFIXm   : US FRAGMENTm ;

NEWLINE : '\r'? '\n' ;

fragment US : '_' ;

fragment FRAGMENTln : 'ln' ;
fragment FRAGMENTlog : 'log' ;
fragment FRAGMENTA : 'A' ;
fragment FRAGMENTm : 'm' ;
fragment FRAGMENTig : 'ig' ;
fragment FRAGMENTres : 'res' ;
fragment FRAGMENTV : 'V' ;

// end of file

and applied to this (from my point of view valid) input:

A
ln_A
A_ig
ln_A_ig
ln_m_m

And I get this error message: 1:0 mismatched input 'A' expecting {'and', 'or', 'not', '='}

All sample lines seem to be wrong for ANTLR.

Where is the error(s) in my grammar?

Oliver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0