maj lexer

This commit is contained in:
trochas
2025-02-14 12:43:36 +01:00
parent 7b82f384e4
commit 8518da7b7b
3 changed files with 8 additions and 3 deletions

View File

@@ -26,4 +26,6 @@ G: '"'
// Whitespaces are ignored. // Whitespaces are ignored.
fragment WS: (' ' | '\n' | '\t' | '\r' | '\u000C'); fragment WS: (' ' | '\n' | '\t' | '\r' | '\u000C');
WSS: WS+ { skip(); }; WSS: WS+ { skip(); };
ID: ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9'|'_')*; ID: ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*;
STRING: ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|' '|'-'|'é'|'è'|'&')+;
//STRING: '"'(~('"'))+'"';

View File

@@ -62,11 +62,10 @@ verbe returns[String val] :
comp[TurtleAST parent] : comp[TurtleAST parent] :
LC i=ID RC //<ID> LC i=ID RC //<ID>
{parent.addComplement($i.text,false);} {parent.addComplement($i.text,false);}
| G i=ID G //"ID" | G i=STRING G //"STRING"
{parent.addComplement($i.text,true);} {parent.addComplement($i.text,true);}
; ;
entity returns[String val] : entity returns[String val] :
i=ID i=ID
{$val = $i.text;} {$val = $i.text;}
; ;

View File

@@ -52,10 +52,12 @@ public class TurtleAST {
public void addSujet(String sujet){ public void addSujet(String sujet){
this.currentSujet=sujet; this.currentSujet=sujet;
System.out.println("debug : sujet = " + sujet);
} }
public void addVerbe(String verbe){ public void addVerbe(String verbe){
this.currentVerbe=verbe; this.currentVerbe=verbe;
System.out.println("debug : verbe = " + verbe);
} }
public void addComplement(String complement, Boolean isText){ public void addComplement(String complement, Boolean isText){
@@ -64,6 +66,8 @@ public class TurtleAST {
EntityImp c = new EntityImp(complement, isText); EntityImp c = new EntityImp(complement, isText);
PhraseImp phrase = new PhraseImp(s,v,c); PhraseImp phrase = new PhraseImp(s,v,c);
this.listPhrases.add(phrase); this.listPhrases.add(phrase);
System.out.println("debug : complement = " + complement);
} }
public void finishNtriple(){ public void finishNtriple(){