Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8932309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:18:06+00:00 2026-06-15T09:18:06+00:00

I started playing around with xtext a few days ago and just went through

  • 0

I started playing around with xtext a few days ago and just went through the tutorials. Maybe the solution has been covered in the reference somewhere but I cannot get it right quickly.

My problem is this. I tried to write a simple grammar which mixed in org.eclipse.xtext.common.Terminals . Then I wanted to insert a cusotm terminal FILE_NAME like this:

terminal FILE_NAME:
( !('/' | '\\' | ':' | '*' | '?' | '"' | '<' | '>' | '|') )+
;

That’s basically what a filename is allowed to be under Windows. However, by doing that, inherited rules like ID, INT, etc. would never be matched, because they are always generated after custom terminals.

Can that kind of problem be avoided gracefully (as repeatless as possible and as general as possible)? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:18:07+00:00Added an answer on June 15, 2026 at 9:18 am

    Terminal rules (aka lexer rules) are used to tokenize the input sequenze. IMHO there should be a minimum of semantics in terminal rules.

    You try to express a specialized parser rule which accepts only valid file names.

    Have a look at parser phases described in the Xtext Documentation [1]. My suggestion:

    1. Lexing: Instead of using a specialized terminal rule go with STRING.

    2. Validation: Write a validation rule for an EClass with a ‘fileName’ EAttribute.

    as repeatless as possible and as general as possible

    You don’t want to repeat your validation for every EClass with a ‘fileName’ EAttribute. Introduce a new super type with a ‘fileName’ EAttribute if you have a refined Ecore model.

    Than you can implement one general validation rule #check_fileName_is_valid(ElementWithFile).

    And if you don’t have a refined MM use meta model hints within your grammar. If you provide a generalized super type Xtext’s Ecore inferrer will pull up common features of the subtypes. Ex:

    ElementWithFile: A | B;
    A: ... 'file' fileName=STRING ...;
    B: ... 'file' fileName=STRING ...;
    // => Ecore: ElementWithFile.fileName<EString>
    

    [1] http://www.eclipse.org/Xtext/documentation.html#DSL

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A few years ago we started playing around with XForms from the W3C for
Just started playing around with ice_cube I've got a weekly schedule (with a granularity
I just started playing around with threading today and I ran into something that
I just started playing around with the 960 CSS framework and found that it
I'm just started on playing around with the canvas HTML5-object. For the sake of
I'm just getting started with ASP.NET MVC 2, and playing around with Validation. Let's
I just started playing around with WPF today, and I couldn't find the datagridview
I've just started playing around with android, so pardon me if this is a
Ok...so I've just started playing around with Codeigniter. I've followed the two tuts on
Possible Duplicate: Is JavaScript's Math broken? I have just started playing around with Javascript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.