Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #2921

Re: How do you create a grammar for a multi-language language?

From gah4 <gah4@u.washington.edu>
Newsgroups comp.compilers
Subject Re: How do you create a grammar for a multi-language language?
Date 2022-03-06 21:22 -0800
Organization Compilers Central
Message-ID <22-03-016@comp.compilers> (permalink)
References <22-03-004@comp.compilers> <22-03-009@comp.compilers> <22-03-015@comp.compilers>

Show all headers | View raw


On Sunday, March 6, 2022 at 8:43:43 PM UTC-8, Hans-Peter Diettrich wrote:

(snip)
> My conclusion:
> A single (formal) grammar can not contain multiple languages. Unless you
> specify that e.g. statements and expressions in a programming language
> shall be considered subject to different languages. Such nitpicking is
> not worth further thoughts :-(

It would be complicated for compiled languages.

TeX allows one to change, character by character in the input, which characters
are letters, and so used in a control sequence name.

LaTeX macros, to allow for internal names that don't conflict with any
user defined names, puts an @ sign in them, after changing @ to a letter.
Then, just before going into user code, changes @ back to not a letter.
(Specifically, it is other.) The lexer can't read too far ahead, as the character
codes might change at any time.

It is also interesting to see how languages without reserved
words, keep track of which words have the keyword meaning,
and which are ordinary names.
[Back in the 1970s there were a bunch of extendible languages like EL/1 and
IMP72 where you could add and change syntax on the fly.  They all died since
it meant that in practice no two programs were written in the same language
and they were unreadable.  Now we have overloading so you understand the
syntax but you don't know what it means. -John]

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-03 13:57 +0000
  Re: How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-05 22:29 +0000
    Re: How do you create a grammar for a multi-language language? "Kartik Agaram" <ak@akkartik.com> - 2022-03-05 16:55 -0800
    RE: How do you create a grammar for a multi-language language? Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-03-06 15:37 +0200
      Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 14:36 -0800
        Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 16:50 -0800
      RE: How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-06 23:32 +0000
  Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-05 21:10 -0800
    Re: How do you create a grammar for a multi-language language? "Robin Vowels" <robin51@dodo.com.au> - 2022-03-07 13:39 +1100
  Re: How do you create a grammar for a multi-language language? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-03-06 12:23 +0100
    Re: How do you create a grammar for a multi-language language? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-03-07 05:08 +0100
      Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 21:22 -0800
        Keywords and Reserved Words Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-03-08 21:46 +0200
          Re: Keywords and Reserved Words gah4 <gah4@u.washington.edu> - 2022-03-09 00:31 -0800
            Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 10:00 +1100
          Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 09:55 +1100
            Re: Keywords and Reserved Words in Fortran Thomas Koenig <tkoenig@netcologne.de> - 2022-03-10 07:07 +0000
          Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 11:59 +1100

csiph-web