Re: Question about lexing

@5, I tried using a set of regular expressions using std::regex:

  • [_a-zA-Z][_a-zA-Z0-9]+ for identifiers;

  • [1-9]\d* for integers; and

  • [-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? for reals

Problem is the last one. My professor gives the following regular expressions for each item:

Word                   { L ( L |  D ) * }
Integer                 {  D+ }
Real                      {  D*.D+ | (D*.D+ (E | e) (((+| -)DDD)|DDD)  }
Special                 { , | ( | ) | [ | ] | ; | < | > | * | / | + | - | = }

Obviously, the _ in the regular _expression_ for identifiers is not within this list, but I added it because its pretty standard for any language to allow underscores in identifiers, and I don't know a language that doesn't. My first thoughtfor the special characters one was to do something like [,()\[\];<>*/+-=], but I'm not sure if that's the most accurate _expression_. I'm doing this with std::regex, but I've never used it before, so this is a new learning experience for me. I'm just happy that the STL finally includes that functionality, clunky as it might be.
Edit: also, std::variant is... Kinda nice, I guess. I suspect its a lot bulkier than normal unions though.



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Nuno via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector

Reply via email to