What is the difference between syntax and s-expressions

What are the main differences between the syntax language and the s-expression language? Does the use of s-expressions affect the compilation time (in the process of parsing) or does it bring any advantage to the language?

+4
source share
2 answers

In a language such as Lisp or Scheme, using S expressions to represent program text is likely to reduce the amount of work for the parser. The Lisp compiler will spend less time parsing Lisp source code than the C ++ compiler will parse C ++ code (C ++ has a reputation as one of the most complex languages ​​for parsing).

However, with a few exceptions (perhaps C ++?), Parsing is not part of the compiler that will take the most time. Java, Python, C #, Delphi have fairly simple grammars.

+1
source

Representation of the source code in the language, since S-expressions make its parsing simple, but this is not the point. Various Lisp dialects have mechanisms for programs that work in the structure of other programs, and which require programs to have a transparent, canonical representation. This representation is S-expressions. This is what Lisp provides for things like macros, code that executes on a program at compile time, which are almost impossible in languages ​​that don't encode programs as data structures in the language.

+1
source

All Articles