Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alang-grupoa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
albruiz
alang-grupoa
Commits
e28a2fdf
Commit
e28a2fdf
authored
Jun 11, 2020
by
marivil
Browse files
Options
Downloads
Patches
Plain Diff
Añadido string como expresion
parent
c9b77487
No related branches found
No related tags found
1 merge request
!1
Arbol
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
astree.c
+1
-1
1 addition, 1 deletion
astree.c
inter05.l
+3
-3
3 additions, 3 deletions
inter05.l
inter05.y
+12
-12
12 additions, 12 deletions
inter05.y
pruebita.c
+5
-0
5 additions, 0 deletions
pruebita.c
with
21 additions
and
16 deletions
astree.c
+
1
−
1
View file @
e28a2fdf
...
...
@@ -326,7 +326,7 @@ static void proc(ast_t *root)
printf
(
"%s%g
\n
"
,
sv
(
left
(
root
)),
expr
(
right
(
root
)));
}
break
;
case
READ
:
case
SCAN
:
if
(
left
(
root
)
==
NULL
)
{
double
rval
;
...
...
This diff is collapsed.
Click to expand it.
inter05.l
+
3
−
3
View file @
e28a2fdf
...
...
@@ -28,12 +28,12 @@ char *keywords[KWLEN] = {
"mcd",
"mcm",
"print",
"read",
"sin",
"tan",
"var",
"while",
"do"
"do",
"scan"
};
/* Identificadores de las palabras clave */
...
...
@@ -48,12 +48,12 @@ unsigned keycodes[KWLEN] = {
MCD,
MCM,
PRINT,
READ,
SIN,
TAN,
VAR,
WHILE,
DO,
SCAN
};
static void lower(char *s);
...
...
This diff is collapsed.
Click to expand it.
inter05.y
+
12
−
12
View file @
e28a2fdf
...
...
@@ -16,7 +16,7 @@
#include "token.h"
#define IN_PARSER
#include "inter05.h"
//mirar cambios
#include "inter05.h"
int yylex(void);
...
...
@@ -27,13 +27,10 @@ FILE *fIn;
int yyerror(char *str);
// Creacion del arbol
static ast_t *astRoot = NULL;
%}
%union {
struct sStackType {
// Tipo para elementos sintacticos
// Para identificar el tipo
unsigned char flag;
union {
double vFloat;
...
...
@@ -64,7 +61,7 @@ static ast_t *astRoot = NULL;
// Tokens
%token <s> IDENT
%term VAR PRINT SIN COS TAN
READ
ARCSIN ARCCOS ARCTAN MCM MCD IF ELSE DO WHILE LOG
%term VAR PRINT SIN COS TAN
SCAN
ARCSIN ARCCOS ARCTAN MCM MCD IF ELSE DO WHILE LOG
%token <s> FLOAT
%token <s> STR
%token <s> CHAR
...
...
@@ -209,15 +206,15 @@ funcionSistema
$$.flag = fAST;
$$.u.ast = mkNd(PRINT, mkSlf(STR,$3.u.vStr), $5.u.ast);
}
|
READ
'(' IDENT ')'
|
SCAN
'(' IDENT ')'
{
$$.flag = fAST;
$$.u.ast = mkNd(
READ
, NULL, mkSlf(IDENT,$3.u.vStr));
$$.u.ast = mkNd(
SCAN
, NULL, mkSlf(IDENT,$3.u.vStr));
}
|
READ
'(' STR ',' IDENT ')'
|
SCAN
'(' STR ',' IDENT ')'
{
$$.flag = fAST;
$$.u.ast = mkNd(
READ
, mkSlf(STR,$3.u.vStr), mkSlf(IDENT,$5.u.vStr));
$$.u.ast = mkNd(
SCAN
, mkSlf(STR,$3.u.vStr), mkSlf(IDENT,$5.u.vStr));
}
;
...
...
@@ -332,6 +329,11 @@ expresion
$$.flag = fAST;
$$.u.ast = mkClf(CHAR,$1.u.vChar);
}
| STR
{
$$.flag = fAST;
$$.u.ast = mkSlf(STR,$1.u.vStr);
}
| IDENT
{
$$.flag = fAST;
...
...
@@ -387,7 +389,6 @@ expresion
%%
// Error sintáctico: impresión del error
int yyerror(char *str) {
prError(yylineno,"%s\n",str,NULL);
return 1;
...
...
@@ -395,9 +396,8 @@ int yyerror(char *str) {
extern FILE *yyin;
// Programa principal (lanzador)
int main(int argc, char *argv[]) {
exitOnError();
// Se indica que si hay errores se finaliza la ejecución
exitOnError();
// Impresión de funcionamiento
if (argc!=2) {
...
...
This diff is collapsed.
Click to expand it.
pruebita.c
+
5
−
0
View file @
e28a2fdf
...
...
@@ -18,8 +18,13 @@ if (true)
}
print
(
x_
%
2
);
print
(
-
x_
);
print
(
x_
);
if
(
x_
>
10
||
!
true
)
{
print
(
"Si esta bien"
);
}
var
nuevavariable
=
" "
;
scan
(
"HOLA AMIGOS"
,
nuevavariable
);
print
(
nuevavariable
);
/* HOLA PUTA*/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment