Re: Parsing / Lexing question & P-code

"Sebastian Moleski" <>
25 Apr 2000 02:26:13 -0400

          From comp.compilers

Related articles
Parsing / Lexing question & P-code (Nicolás) (2000-04-14)
Re: Parsing / Lexing question & P-code (Herwig Huener) (2000-04-21)
Re: Parsing / Lexing question & P-code (Keith Thompson) (2000-04-25)
Re: Parsing / Lexing question & P-code (Sebastian Moleski) (2000-04-25)
| List of all articles for this month |

From: "Sebastian Moleski" <>
Newsgroups: comp.compilers
Date: 25 Apr 2000 02:26:13 -0400
Organization: Nikoma Mediaworks GmbH
References: 00-04-100
Keywords: Pascal, OOP, parse


We are currently working on a compiler for a Pascal like language with
a lot of OOP extensions using plain C++. We haven't used a parser
generator but wrote all of the parsing code ourselves. Our grammar
dictates the following for the assignment statement:

Assignment ::= RefExpression [AssignOp Expression]

RefExpression is an expression that can be assigned to. It's defined
as follows:

RefExpression ::= ['&'] SelValue {'.' SelValue}
SelValue ::= RefName {AccessSpec}
AccessSpec ::= ArrayAccess | MethodInvocation | PointerDeref
ArrayAccess ::= '[' ExpressionList ']'
MethodInvocation ::= '(' [Expression] {',' [Expression]} ')'
PointerDeref ::= '^'

Ignore the ['&'] ater RefExpression, it's a language enhancement.

The parser will get the name from the scanner and look up the
definition of this name. If it is a method and the following is a '(',
the appropriate functions are called. The question whether the
expression is indeed assignable is done at the end if it finds an ':='
token. All this is necessary because all of the following must

f := 12;
a[12] := 12;
p^ := 5;
g^ := 15;

where f is an integer variable, a is an array of integers variable, p
is a pointer to an integer, and g is a function that returns an


Sebastian Moleski

P.S. If you are interested in an extended development of a compiler of
a pascal-like language, please contact me. It's a non-profit project
which will probably go open source as soon as something presentable is
done. Already, there's a strong code base handling type definitions,
constant expressions, qualified names, classes, and a lot of other
nifty language constructs. The compiler is written entirely in C++
with a lot of classes and some templates. Hope you're interested.

The Borland C++ Builder bug lists:

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.