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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:54:57+00:00 2026-05-30T19:54:57+00:00

I am using Lex/Bison to create a simple scripting language which translates into C.

  • 0

I am using Lex/Bison to create a simple scripting language which translates into C. A trans-compiler.

I know Bison can verify syntax, but what about scoping? Can it verify the an identifier that is being used was declared before? Does that have to be done manually? And if so, at which step?

E.g. This is syntax-wise correct. But is should not compile because message is in the wrong scope. In addition, message2 was never declared.

String s1
if (s1=='knock on door')
   String message1='Hello';

print message1;
print message2;
  • 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-05-30T19:54:58+00:00Added an answer on May 30, 2026 at 7:54 pm

    Parsers (however produced) typically cannot check scoping rules.

    To do scope checking in general, in general you have to build the entire AST and then verify the identifiers are well-scoped. For languages which have static scoping with scopes introduced before variable use, you might be able to do this only the fly in rules. For languages with namespaces, the namespace declaration might occur anywhere, and you can’t do it without collecting that namespace and thus the entire program. (The namespace declaration might not even be in the same file as the use; now you have parse an entirely different file).

    As a consequence, the usual way scope checking is done is after parsing, over the program tree. Normally if you are going to do anything beyond parsing, you need the tree, and the full symbol table anyway, so this isn’t really much of an annoyance.

    Some early compilers didn’t have the luxury of holding the entire tree in memory. Either they had languages with scope declarations before use, or they were implemented in multiple passes.

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

Sidebar

Related Questions

I am developing a simple translator from MathML to Latex, using Lex and Yacc.
I'm using lex in my program and I've run into a problem I need
Hi I am using ActivePerl 5.10.1 on Win XP. I can't find Lex package
How much time would it take to write a C++ compiler using lex/yacc? Where
I have a simple language that I'm using Flex(Lexical Analyzer), it's like this: /*
I'm trying to write a shell using yacc and lex and I'm running into
I'm trying to parse Bibtex files using lex/yacc. Strings in the bibtex database can
Problem: I have a project which I'm porting from Solaris/Lex/Yacc to Linux/Flex/Bison + Autotools.
i want to create a php parser.i was thinking of using lex/yacc for the
In Lex i can start a new state using the keyword BEGIN STATE1. I

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.