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 8002205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:17:17+00:00 2026-06-04T16:17:17+00:00

There is 4 lexical elements of grammar G = (S, N, T, P) Where

  • 0

There is 4 lexical elements of grammar

G = (S, N, T, P)

Where G = Grammar, S = Start Symbol, N = Non-Terminals, T = Terminals, P = Production rules

I wanted to know if N is always equal with P because as I know P are lexemes which may replace with other lexemes

So in this example:

<program> --> <stmts>
<stmts> --> <stmt> | <stmt> ; <stmts>
<stmt> --> <var> = <expr>
<var> --> a | b | c | d
<expr> --> <term> + <term> | <term> - <term>
<term> --> <var> | const

S: <program>
N: <program>, <stmts>, <var>, <expr>, <term>
T: ;, a, b, c, d, +, -, const
P: <program>, <stmts>, <var>, <expr>, <term>

Is that right?

  • 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-04T16:17:19+00:00Added an answer on June 4, 2026 at 4:17 pm

    No. |N| does not necessarily = |P|. Consider:

    <program> --> <stmts>
    <stmts> --> <stmt> 
    <stmts> -->| <stmt> ; <stmts>
    <stmt> --> <var> = <expr>
    <var> --> a 
    <var> --> b
    <var> --> c
    <var> --> d
    <expr> --> <term> + <term> 
    <expr> --> <term> - <term>
    <term> --> <var> 
    <term> --> const
    

    Your problem is that you are not precise about what is allowed in a grammar rule.

    You can force the number of rules to match nonterminals, by insisting that no rule has the same left hand side. To do that, you can’t insist on simple BNF; you have to have extended BNF with at least alternation.

    PS: This isn’t really about “lexical elements” of a grammar. It is just about the definition of a grammar.

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

Sidebar

Related Questions

Does any programming language use =/= for not-equal? Are there any lexical difficulties for
I want to create a CSS2.1 lexical scanner based on flex. There is scanner
There are many lexical analyzer and parser generators out there - lex/flex and yacc/bison,
I'm very new to C++, boost etc. I would like to know if there
Is there a way to do something like lexical closures using macrolet? What I
Is there a language specification for clojure? Something that precisely defines the lexical syntax
JavaScript has lexical scoping which means that non-local variables accessed from within a function
I was wondering. Is there any lexical/syntax analizer (like Flex/Bison) that would work on
Is there a way to serialize a lexical closure in Python using the standard
I read about lexical-let's memory leak, for example here: Are there any problems with

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.