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

  • SEARCH
  • Home
  • 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 8354849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:40:59+00:00 2026-06-09T09:40:59+00:00

I am trying to model mqsi commands, using ANTLR and have come across the

  • 0

I am trying to model mqsi commands, using ANTLR and have come across the following problem. The documents for mqsicreateconfigurableservice say for the queuePrefix :
“The prefix can contain any characters that are valid in a WebSphere® MQ queue name, but must be no longer than eight characters and must not begin or end with a period (.). For example, SET.1 is valid, but .SET1 and SET1. are invalid. Multiple configurable services can use the same queue prefix.”

I’ve used the following, as a stopgap but this technique implies I must have a minimum of a two character name and seems a very wasteful and non-scalable solution. Is there a better method?

See ‘queuePrefixValue’, below…

Thanks :o)

parser grammar mqsicreateconfigurableservice;
mqsicreateconfigurableservice
:   'mqsicreateconfigurableservice' ' '+ params
;
params  :   (broker ' '+ switches+)
;
broker  :   validChar+
;
switches
:   AggregationConfigurableService
;
AggregationConfigurableService
:    (objectName ' '+ AggregationNameValuePropertyPair)
;

objectName
:   (' '+ '-o' ' '+ validChar+)
;

AggregationNameValuePropertyPair
:   (' '+ '-n' ' '+ 'queuePrefix' ' '+ '-v' ' '+ queuePrefixValue)?
    (' '+ '-n' ' '+ 'timeoutSeconds' ' '+ '-v' ' '+  timeoutSecondsValue)?
;

// I'm not satisfied with this rule as it means at least two digits are mandatory
//Couldn't see how to use regex or semantic predicates which appear to offer a solution
queuePrefixValue
:   validChar (validChar | '.')? (validChar | '.')? (validChar | '.')? (validChar | '.')? (validChar | '.')? (validChar | '.')? validChar
;
timeoutSecondsValue //a positive integer
:   ('0'..'9')+
;

//This char list is just a temporary subset which eventually needs to reflect all the WebSphere acceptable characters, apart from the dot '.'
validChar
:   (('a'..'z')|('A'..'Z')|('0'..'9'))
;
  • 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-09T09:41:01+00:00Added an answer on June 9, 2026 at 9:41 am

    You’re using parser rules where you should be using lexer rules instead 1. The . (the dot meta-char) and .. (the range meta-char) behave differently in parser rules as they do in lexer rules. In parser rules, . matches any token (in lexer rules they match any character) and .. will match token-ranges, not character ranges as you’re expecting them to match!

    So, make queuePrefixValue a lexer rule (let it start with an upper case letter: QueuePrefixValue), and use fragment rules 2 where appropriate. Your QueuePrefixValue could look like this:

    QueuePrefixValue
     : StartEndCH ((((((CH? CH)? CH)? CH)? CH)? CH)? StartEndCH)?
     ;
    
    fragment StartEndCH
     : 'a'..'z'
     | 'A'..'Z'
     | '0'..'9'
     ;
    
    fragment CH
     : '.'
     | StartEndCH
     ;
    

    So, that more or less answers your question: no, there is no short way to restrict a token to have a certain amount of characters without a language-specific predicate. Note that my suggestion above is not ambiguous (your QueuePrefixValue is ambiguous) and mine also accepts single character values.

    HTH


    1 Practical difference between parser rules and lexer rules in ANTLR?

    2 What does "fragment" mean in ANTLR?

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

Sidebar

Related Questions

I'm trying to model my app and I've come across this problem: I have
While trying to model my domain, I came across the following problem. Let's image
I am trying to model a network using C++. I have a struct called
I am trying to model the following table structure in Symfony 2.0 using annotations.
I am trying to model a given Problem using State Machine (.Net framework 4.0
I'm trying to model artists and songs and I have a problem where I
basically I am trying to model some map brushes that have the following format:
I am trying to model a simple domain by using DDD. Database layer is
I'm trying to model a asynchronous job processing framework using MailboxProcessor. My requirements are
I am trying to model a transfer function block for say 1/(s+1). What is

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.