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


Groups > comp.compilers > #3427 > unrolled thread

Re: A simpler way to tokenize and parse?

Started byChristopher F Clark <christopher.f.clark@compiler-resources.com>
First post2023-03-26 17:11 +0300
Last post2023-03-27 05:08 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.compilers


Contents

  Re: A simpler way to tokenize and parse? Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2023-03-26 17:11 +0300
    Re: A simpler way to tokenize and parse? Thomas Koenig <tkoenig@netcologne.de> - 2023-03-27 05:08 +0000

#3427 — Re: A simpler way to tokenize and parse?

FromChristopher F Clark <christopher.f.clark@compiler-resources.com>
Date2023-03-26 17:11 +0300
SubjectRe: A simpler way to tokenize and parse?
Message-ID<23-03-025@comp.compilers>
If I recall correctly, at one time, PCCTS and it’s related tool
Sorcerer used an S-expression-like representation for ASTs, including an
equivelnt to CAR and CDR, whose names I don’t recall but they were
something like “down” and “right”.

More recent versions of ANTLR don't expose that as far at I have seen,
preferring to use a Visitor pattern for traversals.

[toc] | [next] | [standalone]


#3429

FromThomas Koenig <tkoenig@netcologne.de>
Date2023-03-27 05:08 +0000
Message-ID<23-03-027@comp.compilers>
In reply to#3427
Christopher F Clark <christopher.f.clark@compiler-resources.com> schrieb:
> If I recall correctly, at one time, PCCTS and it’s related tool
> Sorcerer used an S-expression-like representation for ASTs, including an
> equivelnt to CAR and CDR, whose names I don’t recall but they were
> something like “down” and “right”.

S-expressions are a fairly natural representation of using trees,
at least for expressions.

An example: If you use gfortran's -fdump-fortran-original option, you
will get its internal expression after parsing on standard output.

For example, the code of

real function foo(x,y)
  foo = 2.3 + 5.0*x*y
end function foo

is represented as

  ASSIGN foo:foo (+ 2.29999995 (* (* 5.00000000 foo:x) foo:y))

where the internal representation is a tree.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.compilers


csiph-web