Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // prueba.gram
- Lenguaje: C;
- {
- Programa -> Librerias Main; # Programa principal
- Librerias -> \#include <Identificador.h> (,Librerias)?;
- Main -> void main\(\){ Variables };
- Variables -> TipoDato ListaDeIdentificadores\;;
- ListaDeIdentificadores -> Identificador (,ListaDeIdentificadores)?;
- Prueba -> \#|(Numero Programa)|(Identificador Numero?);
- Anidado -> (\? (Numero Programa)?)?;
- }
- // Lenguaje.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Generador
- {
- class Lenguaje : Sintaxis
- {
- public Lenguaje() : base()
- {
- }
- public Lenguaje(string filePath) : base(filePath)
- {
- }
- public void Programa()
- {
- Librerias();
- Main();
- }
- private void Librerias()
- {
- Match("#");
- Match("include");
- Match("<");
- Match(c.Identificador);
- Match(".");
- Match("h");
- Match(">");
- if (getContenido() == ",")
- {
- Match(",");
- Librerias();
- }
- }
- private void Main()
- {
- Match("void");
- Match("main");
- Match("(");
- Match(")");
- Match("{");
- Variables();
- Match("}");
- }
- private void Variables()
- {
- Match(c.TipoDato);
- ListaDeIdentificadores();
- Match(";");
- }
- private void ListaDeIdentificadores()
- {
- Match(c.Identificador);
- if (getContenido() == ",")
- {
- Match(",");
- ListaDeIdentificadores();
- }
- }
- private void Prueba()
- {
- if (getContenido() == "#")
- Match("#");
- else
- if (getClasificacion() == c.Numero)
- {
- Match(c.Numero);
- Programa();
- }
- else
- {
- Match(c.Identificador);
- if (getClasificacion() == c.Numero)
- Match(c.Numero);
- }
- }
- private void Anidado()
- {
- if (getContenido() == "?")
- {
- Match("?");
- if (getClasificacion() == c.Numero)
- {
- Match(c.Numero);
- Programa();
- }
- }
- }
- }
- }
- // Program.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Generador
- {
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- Lenguaje L = new Lenguaje("C:\\archivos\\prueba.cs\\");
- L.Programa();
- Console.ReadKey();
- Console.WriteLine();
- L.closeFiles();
- }
- catch (MyException) { }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement