Aktív témák
-
zeronero
csendes tag
Alábbi nyelvhez kéne:
pogram oszto
integer a;
integer i;
integer oszto;
boolean vanoszto;
begin
read( a );
vanoszto := false;
i := 2;
while not vanoszto and i < a do
if a mod i = 0 then
vanoszto := true;
oszto := i;
endif
i := i+1;
done
if vanoszto then
write( vanoszto );
write( oszto );
else
write( vanoszto );
endif
end---------------------------------------------------------------------------------------------------------------------------------
while.l%option noyywrap c++
%{
#include <iostream>
#include <stdlib.h>
#include "Parser.h"
%}
SZAMJEGY [0-9]
WS [ \t\n]
BETU [a-zA-Z]
%%
program return Parser::PROGRAM;
begin return Parser::BEGIN;
end return Parser::END;
integer return Parser::INTEGER;
boolean return Parser::BOOLEAN;
skip return Parser::SKIPTHIS;
if return Parser::IF;
then return Parser::THEN;
else return Parser::ELSE;
endif return Parser::ENDIF;
while return Parser::WHILE;
do return Parser::DO;
done return Parser::DONE;
read return Parser::READ;
write return Parser::WRITE;
";" return Parser::SEMICOL;
":=" return Parser::ASSIGN;
"=" return Parser::EQUAL;
"<" return Parser::LESS;
">" return Parser::MORE;
"+" return Parser::PLUS;
"-" return Parser::MINUS;
"*" return Parser::MULT;
and return Parser::AND;
or return Parser::OR;
not return Parser::NOT;
div return Parser::DIV;
mod return Parser::MOD;
"(" return Parser::LPAR;
")" return Parser::RPAR;
{SZAMJEGY}+ return Parser::NUMBER; //std::cout << "szamkonstans: " << YYText() <<std::endl;
true return Parser::TRUE;
false return Parser::FALSE;
"#".*\n // nem kell semmit csinalni
{BETU}({BETU}|{SZAMJEGY}|_)* return Parser::VARIABLE; //std::cout << "azonosito: " << YYText() <<std::endl;
{WS}+ // feher szokozok: semmi teendo
. {
std::cerr << "Lexikalis hiba!" << std::endl;
exit(0);
}
%%WHILE.Y-----------------------------------------------------------------------------------------------
%baseclass-preinclude <iostream>
%stype int
%token SKIPTHIS
%token BEGIN END PROGRAM VARIABLE
%token WHILE DO DONE IF THEN ENDIF ELSE SEMICOL LPAR RPAR TRUE FALSE WRITE READ ASSIGN
%token NUMBER
%token ENDLINE
%token INTEGER
%token BOOLEAN
%left NOT
%left OR
%left AND
%left EQUAL
%left LESS MORE
%left PLUS MINUS
%left MULT DIV MOD
%%
start:
PROGRAM VARIABLE declarations blokk
{
std::cout << "start -> PROGRAM VARIABLE declarations blokk" << std::endl;
}
;
blokk:
BEGIN program_lines END
{
std::cout << "blokk -> BEGIN program_lines END" << std::endl;
}
;
program_lines:
program_line
{
std::cout << "program_line -> program_line" << std::endl;
}
|
program_line program_lines
{
std::cout << "program_line -> program_line program_lines" << std::endl;
}
;
program_line:
SKIPTHIS ENDLINE
{
std::cout << "program_line -> SKIPTHIS ENDLINE" << std::endl;
}
|
statement
{
std::cout << "program_line -> statement" << std::endl;
}
|
ENDLINE
{
std::cout << "program_line -> ENDLINE" << std::endl;
}
|
function
{
std::cout << "program_line -> function ENDLINE" << std::endl;
}
;
statement:
WHILE condition DO program_lines DONE
{
std::cout << "statement-> WHILE condition DO program_lines DONE" << std::endl;
}
|
IF condition THEN program_lines ENDIF
{
std::cout << "statement -> IF condition THEN program_lines ENDIF" << std::endl;
}
|
IF condition THEN program_lines ELSE program_lines ENDIF
{
std::cout << "statement -> IF condition THEN program_lines ELSE program_lines ENDIF" << std::endl;
}
;
declarations:
declaration
{
std::cout << "declarations -> declaration" << std::endl;
}
|
declaration declarations
{
std::cout << "declarations -> declaration declarations" << std::endl;
}
;
declaration:
INTEGER VARIABLE SEMICOL
{
std::cout << "declaration -> INTEGER VARIABLE SEMICOL" << std::endl;
}
|
BOOLEAN VARIABLE SEMICOL
{
std::cout << "declaration -> BOOLEAN VARIABLE SEMICOL" << std::endl;
}
;
condition:
LPAR condition RPAR
{
std::cout << "condition -> LPAR condition RPAR" << std::endl;
}
|
VARIABLE
{
std::cout << "condition -> VARIABLE" << std::endl;
}
|
TRUE
{
std::cout << "condition -> TRUE" << std::endl;
}
|
FALSE
{
std::cout << "condition -> FALSE" << std::endl;
}
|
exp EQUAL exp
{
std::cout << "condition -> exp EQUAL exp" << std::endl;
}
|
exp LESS exp
{
std::cout << "condition -> exp LESS exp" << std::endl;
}
|
exp MORE exp
{
std::cout << "condition -> exp MORE exp" << std::endl;
}
|
condition AND condition
{
std::cout << "condition -> condition AND condition" << std::endl;
}
|
condition OR condition
{
std::cout << "condition -> condition OR condition" << std::endl;
}
|
NOT condition
{
std::cout << "condition -> NOT condition" << std::endl;
}
;
function:
WRITE LPAR VARIABLE RPAR SEMICOL
{
std::cout << "function -> WRITE LPAR VARIABLE RPAR SEMICOL" << std::endl;
}
|
READ LPAR VARIABLE RPAR SEMICOL
{
std::cout << "function -> READ LPAR VARIABLE RPAR SEMICOL" << std::endl;
}
|
VARIABLE ASSIGN exp SEMICOL
{
std::cout << "function -> VARIABLE ASSIGN exp" << std::endl;
}
;
exp:
VARIABLE
{
std::cout << "exp -> VARIABLE" << std::endl;
}
|
NUMBER
{
std::cout << "exp -> NUMBER" << std::endl;
}
|
exp MOD exp
{
std::cout << "exp -> exp MOD exp" << std::endl;
}
|
exp PLUS exp
{
std::cout << "exp -> exp PLUS exp" << std::endl;
}
|
exp MINUS exp
{
std::cout << "exp -> exp MINUS exp" << std::endl;
}
|
exp MULT exp
{
std::cout << "exp -> exp MULT exp" << std::endl;
}
|
exp DIV exp
{
std::cout << "exp -> exp DIV exp" << std::endl;
}
;
Aktív témák
- Futás, futópályák
- Beköszöntött az űrinternet kora
- sziku69: Fűzzük össze a szavakat :)
- Folyószámla, bankszámla, bankváltás, külföldi kártyahasználat
- iPhone topik
- Audi, Cupra, Seat, Skoda, Volkswagen topik
- Meghalt a Windows 10, éljen a Windows 10!
- Fotók, videók mobillal
- One otthoni szolgáltatások (TV, internet, telefon)
- Gumi és felni topik
- További aktív témák...
- (Használt/Used) Huawei Mate 20 Pro - 128 GB - Midnight Blue (Unlocked/Kártyafüggetlen)
- Gigabyte B450M S2H + Ryzen 5 1400 + MSI GTX 1650 Super 4GB
- "Szinte Új" iPad Pro 12.9 (3. gen) + Apple Pencil 2 + Smart Folio tok
- ASUS TUF Gaming VG34VQL3A 34" Ívelt Gamer Monitor
- AMD Ryzen 5 5600/3080/1TB SSD/32Gb RAM/850W GOLD
Állásajánlatok
Cég: NetGo.hu Kft.
Város: Gödöllő
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest

