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
- Kertészet, mezőgazdaság topik
- MWC 2026: Bajnoki címre pályázik a Xiaomi Watch 5
- Mibe tegyem a megtakarításaimat?
- OLED TV topic
- Melyik tápegységet vegyem?
- Bestbuy játékok
- Allegro vélemények - tapasztalatok
- Motorola Moto G06 Power – nagyfater új zakót vett
- gban: Ingyen kellene, de tegnapra
- Okos otthon - Home Assistant, openHAB és más nyílt rendszerek
- További aktív témák...
- HP EliteBook 840R G4, 14" FHD, i5-8350 CPU, 8-16GB DDR4, 128GB - 1TB SSD, 4G/LTE W11, Számla, 1 év g
- GARIS / ITX méregzsák - AMD Ryzen 9 7900 / 32GB DDR5 / RTX 5070 / stb...
- HP Z240 munkaállomás (több darab) (Intel Core I7-6700, 8GB DDR4)
- Precision 5560 15.6" FHD+ IPS i7-11850H RTX A2000 32GB 512GB NVMe magyar vbill gar
- Samsung Galaxy A55 - 256 GB - kék (311) Újszerű, 10000 Ft kiegészítő ajándék, Garancia
- Konzol felvásárlás!! Xbox Series S, Xbox Serries X
- 237 - Lenovo Legion Pro 5 (16ARX8) - AMD Ryzen 7 7745HX, RTX 4070
- GAMER PC! Intel i7-14700 / RTX 4090 / 32GB DDR5 / 1TB NVMe / 1000w Gold! BeszámítOK
- Lenovo ThinkPad T14 Gen 4 Ryzen 5 PRO 7540U 14" FHD+ 32GB 512GB Lenovo gar: 2028.01.07!
- Lenovo T14 Gen 1 Ryzen 5 pro 4650U, 16GB RAM, 512GB SSD, jó akku, számla, garancia
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
