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


Groups > comp.compilers > #2558

Re: Supporting multiple input syntaxes

From luser droog <mijoryx@yahoo.com.dmarc.email>
Newsgroups comp.compilers
Subject Re: Supporting multiple input syntaxes
Date 2020-08-13 21:36 -0700
Organization Compilers Central
Message-ID <20-08-006@comp.compilers> (permalink)
References <20-08-002@comp.compilers> <20-08-004@comp.compilers>

Show all headers | View raw


On Thursday, August 13, 2020 at 5:22:51 PM UTC-5, Hans-Peter Diettrich wrote:
> Am 13.08.2020 um 00:20 schrieb luser droog:
> > I've got my project successfully parsing the circa-1975 C syntax
> > from that old manual. I'd like to add parsers for K&R1 and c90
> > syntaxes.
> >
> > How separate should these be? Should they be complete
> > separate grammars, or more piecewise selection?
>
> IMO this depends widely on the usage of the parser output (diagnostics,
> backend...). C90 is much stricter than K&R, requires more checks. Do you
> need extensive error diagnostics, or do you assume that all source code
> is free of errors?
>
>
> > https://github.com/luser-dr00g/pcomb/blob/master/pc9syn.c
>
> You seem to implement an LL(1) parser? My C98 Parser is LL(2), i.e. an
> LL(1) parser with one or two locations where more lookahead is required.
> Also identifiers are classified as typenames and others prior to their
> usage.
>

Yes, it's basically LL(1) with backtracking. There's one part of the
grammar I'm using that's left-recursive and I still need to work that
out.

> For real-world testing (recommended!) a preprocessor is required and a
> copy of the standard libraries of existing compiler(s).
>
> Your test_syntax() source misses "=" from the variable declarations
> (initializers). What about pointer syntax/semantics? If you add these
> (and other) syntax differences conditionally (version specific) to your
> code, which way would look better to you? Which way will be safer to
> maintain?
>

That's actually correct for the 1975 dialect: no '=' to initialize
variables. I think it's pretty ugly without it, but it could be
removed anyway for the AST.

>
> Nice code BTW :-)
>

Thanks! I think I need to sidetrack a bit and work up some primitives
for pattern matching and decomposition to make the backend easier.
I'll report back if/when it can do more tricks.

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


Thread

Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-12 15:20 -0700
  Re: Supporting multiple input syntaxes Kaz Kylheku <793-849-0957@kylheku.com> - 2020-08-13 00:43 +0000
  Re: Supporting multiple input syntaxes Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2020-08-13 10:27 +0200
    Re: Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-13 21:36 -0700
    Re: Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-23 22:16 -0700
  Re: Supporting multiple input syntaxes minforth@arcor.de - 2020-08-13 14:15 -0700
    Re: Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-13 21:37 -0700
    RE: Supporting mulitple input syntaxes Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2020-08-14 12:44 +0300
  Supporting multiple input syntaxes David Lovemore <davidlovemore@gmail.com> - 2020-08-15 06:42 -0700
    Re: Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-15 15:20 -0700
      Re: Supporting multiple input syntaxes David Lovemore <davidlovemore@gmail.com> - 2020-08-16 02:21 -0700
        Re: Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-20 14:45 -0700
          Re: Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-23 19:35 -0700
            Re: implementation languages, was Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-23 20:39 -0700
              Re: implementation languages, was Supporting multiple input syntaxes Thomas Koenig <tkoenig@netcologne.de> - 2020-08-24 17:01 +0000
                Re: implementation languages, was Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-28 10:56 -0700
              Re: stack languages, was Supporting multiple input syntaxes luser droog <mijoryx@yahoo.com.dmarc.email> - 2020-08-24 12:14 -0700
  Re: Supporting multiple input syntaxes gah4 <gah4@u.washington.edu> - 2020-08-23 14:26 -0700
  Re: Supporting multiple input syntaxes antispam@math.uni.wroc.pl - 2021-02-11 23:27 +0000
    Re: Supporting multiple input syntaxes Elijah Stone <elronnd@elronnd.net> - 2021-02-17 01:44 -0800
      Re: Supporting multiple input syntaxes antispam@math.uni.wroc.pl - 2021-02-23 23:28 +0000
        Re: Supporting multiple input syntaxes "ltc...@gmail.com" <ltcmelo@gmail.com> - 2021-03-14 21:08 -0400
  Re: Supporting multiple input syntaxes Rock Brentwood <rockbrentwood@gmail.com> - 2021-03-14 17:36 -0700

csiph-web