Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax Error: Unexpected Newline #22

Open
gerardoricor opened this issue May 25, 2023 · 2 comments
Open

Syntax Error: Unexpected Newline #22

gerardoricor opened this issue May 25, 2023 · 2 comments

Comments

@gerardoricor
Copy link

gerardoricor commented May 25, 2023

I found this error. This error is a parse error on line 11. A newline character was encountered unexpectedly instead of one of the expected tokens, indicating a syntax error in the code.

Code:

graph TB
  U["Usuario"] -- "Inicia sesión" --> L["Página de Préstamo"]
  L -- "Click en Añadir Artículo" --> AI["Formulario de Añadir Artículo"]
  AI -- "Llena el formulario y añade accesorio" --> AC["Formulario de Accesorios"]
  AC -- "Marca la casilla de Activo y guarda" --> AI
  AI -- "Guarda el artículo" --> ID["Página de Detalles del Artículo"]
  ID -- "El accesorio aparece como Activo" --> E["Editar Artículo"]
  E -- "El accesorio aparece como Activo" --> EA["Editar Accesorio"]
  EA -- "La casilla de Activo está desmarcada" --> E
  E -- "Guarda sin cambios" --> ID
  ID -- "El accesorio aparece como Inactivo"
  linkStyle 0 stroke:#2ecd71,stroke-width:2px;
  linkStyle 1 stroke:#2ecd71,stroke-width:2px;
  linkStyle 2 stroke:#2ecd71,stroke-width:2px;
  linkStyle 3 stroke:#2ecd71,stroke-width:2px;
  linkStyle 4 stroke:#2ecd71,stroke-width:2px;
  linkStyle 5 stroke:#2ecd71,stroke-width:2px;
  linkStyle 6 stroke:#2ecd71,stroke-width:2px;
  linkStyle 7 stroke:#2ecd71,stroke-width:2px;
  linkStyle 8 stroke:#2ecd71,stroke-width:2px;

Error:

Parse error on line 11:
...arece como Inactivo" linkStyle 0 strok
-----------------------^
Expecting 'SPACE', 'GRAPH', 'DIR', 'subgraph', 'end', 'AMP', 'ALPHA', 'COLON', 'TAGEND', 'START_LINK', 'LINK', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'DOWN', 'UP', 'DEFAULT', 'NUM', 'COMMA', 'MINUS', 'BRKT', 'DOT', 'PCT', 'TAGSTART', 'PUNCTUATION', 'UNICODE_TEXT', 'PLUS', 'EQUALS', 'MULT', 'UNDERSCORE', got 'NEWLINE'
@gerardoricor
Copy link
Author

gerardoricor commented May 25, 2023

Solution:
While working on the Mermaid diagram for the project, I discovered a small error in the diagram syntax which was causing a parsing error. The error was due to a line of code where a connection was made without specifying a destination node. Mermaid syntax requires every connection to have both a source and a destination node.

Specifically, the line of code ID -- "El accesorio aparece como Inactivo" was missing a destination. As such, the diagram could not be generated due to this incomplete instruction. The parser was essentially left waiting for further instructions that never arrived, hence the error.

To resolve this issue, I added a destination node to this line, which I named "Fin". This node represents the end of the workflow in the diagram. The corrected line now reads ID -- "El accesorio aparece como Inactivo" --> F["Fin"].

Moreover, I ensured that all link styles were immediately followed by the connections to which they apply.

With these changes, the diagram now correctly represents our intended process flow and generates without error.

Code:

graph TB
  U["Usuario"] -- "Inicia sesión" --> L["Página de Préstamo"]
  L -- "Click en Añadir Artículo" --> AI["Formulario de Añadir Artículo"]
  AI -- "Llena el formulario y añade accesorio" --> AC["Formulario de Accesorios"]
  AC -- "Marca la casilla de Activo y guarda" --> AI
  AI -- "Guarda el artículo" --> ID["Página de Detalles del Artículo"]
  ID -- "El accesorio aparece como Activo" --> E["Editar Artículo"]
  E -- "El accesorio aparece como Activo" --> EA["Editar Accesorio"]
  EA -- "La casilla de Activo está desmarcada" --> E
  E -- "Guarda sin cambios" --> ID
  ID -- "El accesorio aparece como Inactivo" --> F["Fin"]
  linkStyle 0 stroke:#2ecd71,stroke-width:2px;
  linkStyle 1 stroke:#2ecd71,stroke-width:2px;
  linkStyle 2 stroke:#2ecd71,stroke-width:2px;
  linkStyle 3 stroke:#2ecd71,stroke-width:2px;
  linkStyle 4 stroke:#2ecd71,stroke-width:2px;
  linkStyle 5 stroke:#2ecd71,stroke-width:2px;
  linkStyle 6 stroke:#2ecd71,stroke-width:2px;
  linkStyle 7 stroke:#2ecd71,stroke-width:2px;
  linkStyle 8 stroke:#2ecd71,stroke-width:2px;

@bra1nDump
Copy link
Owner

Unfortunately gpt still makes mistakes when generating these diagrams. I don't think it can really be prevented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants