home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ssvpar.zip
/
SSCALC.YCC
< prev
next >
Wrap
Text File
|
1994-12-01
|
3KB
|
95 lines
//--------------------------------------------------------------
//
// Copyright (c) 1994 SandStone Technology Inc.
// All rights reserved.
//
// This is the calculator rule file described in the Visual
// Parse++ Guide and Reference.
//
//--------------------------------------------------------------
%expression Main
'[ \n\t]+' %ignore;
'/\*' %ignore, %push MLCom;
'//' %ignore, %push SLCom;
';' End, ';';
'\+' Plus, '+';
'\-' Minus, '-';
'\/' Div, '/';
'\*' Mult, '*';
'%' Mod, '%';
'\*\*' Pow, '**';
'[oO][rR]' Or 'or';
'[aA][nN][dD]' And 'and';
'[nN][oO][tT]' Not 'not';
'\(' OParen, '(';
'\)' CParen, ')';
'[1-9][0-9]*' Dec, 'dec';
'0[0-7]*' Oct, 'oct';
'0(x|X)[0-9a-fA-F]+' Hex, 'hex';
//------------------------------------------------------------------------
//
// Process multi line comments
//
//------------------------------------------------------------------------
%expression MLCom
'.' %ignore;
'\n' %ignore;
'\*/' %ignore, %pop;
//------------------------------------------------------------------------
//
// Process single line comments
//
//------------------------------------------------------------------------
%expression SLCom
'.' %ignore;
'\n' %ignore, %pop;
//------------------------------------------------------------------------
//
// Precedence table
//
//------------------------------------------------------------------------
%prec
1, '+', %left;
1, '-', %left;
1, 'or', %left;
2, '*', %left;
2, '/', %left;
2, '%', %left;
2, 'and', %left;
2, 'not', %right;
3, '**', %right;
//------------------------------------------------------------------------
//
// Grammar
//
//------------------------------------------------------------------------
%production start
Start start -> exprStatement;
StartList start -> start exprStatement;
ExprSingle exprStatement -> expr ';';
ExprError exprStatement -> %error ';';
ExprPlus expr -> expr '+' expr;
ExprMinus expr -> expr '-' expr;
ExprMult expr -> expr '*' expr;
ExprDiv expr -> expr '/' expr;
ExprMod expr -> expr '%' expr;
ExprNot expr -> 'not' expr;
ExprAnd expr -> expr 'and' expr;
ExprOr expr -> expr 'or' expr;
ExprNested expr -> '(' expr ')';
ExprNumber expr -> number;
NumberDec number -> 'dec';
NumberOct number -> 'oct';
NumberHex number -> 'hex';