Luis Mateo Hincapié Martínez [email protected] Teoría de lenguajes y Laboratorio Facultad de Ingeniería Universidad de Antioquia 2021 - 1

Sirio

Después de implementar el análisis léxico se adicionara el analizador de sintaxis, el cual mediante gramáticas LL(1) permite revisar la lista ligada o array de tokens, identificando si las estructuras planteadas son correctas y tienen un sentido lógico según sus tipos de token.

En este documento se tratara de explicar la forma en que se implementara y construirá el modulo de análisis de sintaxis de Sirio, las gramáticas, las restricciones y condiciones que se tendrán, así como las estructuras y el diseño que se uso para construirlo.

Generalidades

El lenguaje que Sirio podrá analizar será Dart; un lenguaje de código abierto desarrollado en Google con el objetivo de permitir a los desarrolladores utilizar un lenguaje orientado a objetos con análisis de tipo estático.

Estructuras (Sentencias)

<List_Statement> -> <Statement>
<List_Statement> -> <List_Statement><Statement>

Declarativas

<Statement> -> var <Identifier>;
<Statement> -> var <Identifier> = <Number> | <String> | <Boolean> | <List> | <Map>;
<Statement> -> var <Identifier1> , <Identifier2>, ... , <IdentifierN>;
<Statement> -> var <Identifier1> , <Identifier2>,..., <IdentifierN> = <Number>, <String>,..., <Number>;

<Statement> -> var <Identifier> = <Exp>

Expresiones aritméticas

<Exp> -> <Term><List_Exp>
<List_Exp> -> +<Term><List_Exp>
<List_Exp> -> -<Term><List_Exp>
<List_Exp> -> λ
<Term> -> <Prod><Lista_Term>
<Lista_Term> -> *<Prod><Lista_Term>
<Lista_Term> -> /<Prod><Lista_Term>
<Prod> -> (<Exp>)
<Prod> -> Identificador
<Prod> -> Number

Selectiva

Sentencia If

if(boolean_expression){ 
   // statement(s) will execute if the Boolean expression is true. 
}

if(boolean_expression){ 
   // statement(s) will execute if the Boolean expression is true. 
} else { 
   // statement(s) will execute if the Boolean expression is false. 
}
<Statement> -> <If>
<If> -> if(<Boolean_expression>){<List_Statement>}
<If> -> if(<Boolean_expression>){<List_Statement>}else{<List_Statement>}
<Boolean_expression> -> <logical_cond>
<Boolean_expression> -> <And_cond>
<Boolean_expression> -> <Or_cond>
<logical_cond> -> <logical_cond>&&<logical_cond>
<Or_cond> -> <logical_cond>||<logical_cond>
<logical_cond> -><Exp> > <Exp>
<logical_cond> -><Exp> < <Exp>
<logical_cond> -><Exp> >= <Exp>
<logical_cond> -><Exp> <= <Exp>
<logical_cond> -><Exp> == <Exp>
<logical_cond> -><Exp> != <Exp>

//<List_Statement> ya se ha definido
//<Exp> ya se ha definido

Iterativa